<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[error: &#x27;X&#x27; was not declared in this scope]]></title><description><![CDATA[<p>Hi, bin neu hier und habe ein Problem. Schreibe gerade ein Programm und bekomme dauernd eine Fehler. Es sind eigentlich mehrere aber erstmal interessiert mich nur der Eine.</p>
<p>Der Code lautet:</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;math.h&gt;
using namespace std;

int main (){
	point *A,*B,*C;
	circle *K1,*K2,*K3;
	double r,r1,r2,r3;
        double x,y;
	//...

		//Punkt A
		cout &lt;&lt; &quot;Bitte x y für A eingeben : &quot;;
		cin &gt;&gt; x &gt;&gt; y;
		A = new point(x,y);

		//Punkt B
		cout &lt;&lt; &quot;Bitte x y für B eingeben : &quot;;
		cin &gt;&gt; x &gt;&gt; y;
		B = new point(x,y);

		//Punkt C
		cout &lt;&lt; &quot;Bitte x y für C eingeben : &quot;;
		cin &gt;&gt; x &gt;&gt; y;
		C = new point(x,y);

	//Radien
	r1 = sqrt( pow( A.getX(),2 ) + pow( A.getY(),2 ) ); 
	r2 = sqrt( pow( B.getX(),2 ) + pow( B.getY(),2 ) ); 
	r3 = sqrt( pow( C.getX(),2 ) + pow( C.getY(),2 ) ); 

	if(r1 &gt; r2 &amp;&amp; r1 &gt; r3){
		r = r1;	
	}

	if(r2 &gt; r1 &amp;&amp; r2 &gt; r3){
		r = r2;
                //
	}
	else{
		r = r3;
	}

	//Hilfskreise
	K1 = new circle(A, r);
	K2 = new circle(B, r);
	K3 = new circle(C, r);

	//...
	delete A;
	delete B;
	delete C;

        return 0;
}
</code></pre>
<p>nun kommt immer:</p>
<pre><code>main.cpp:6:2: error: 'point' was not declared in this scope
main.cpp:6:9: error: 'A' was not declared in this scope
main.cpp:6:12: error: 'B' was not declared in this scope
main.cpp:6:15: error: 'C' was not declared in this scope
main.cpp:7:2: error: 'circle' was not declared in this scope
main.cpp:7:10: error: 'K1' was not declared in this scope
main.cpp:7:14: error: 'K2' was not declared in this scope
main.cpp:7:18: error: 'K3' was not declared in this scope
</code></pre>
<p>Also ich habe schon den Fehler gegooglet, aber meistens bezieht sich der Fehler darauf, dass std fehlt.<br />
point und circle sind Klassen, die sich im selben Verzeichnis befinden. Wenn ich mit gedrückten Strg drauf klicke, springt es in die Klasse.<br />
Ich benutze NetBeans IDE 7.2.1 mit MinGW.</p>
<p>Mache ich was grundsätzlich falsch oder ist das ein IDE/Compiler Problem.</p>
<p>Ich hoffe die Infos reichen und mir kann eine helfen.</p>
<p>Gruß<br />
POC</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/310663/error-x-was-not-declared-in-this-scope</link><generator>RSS for Node</generator><lastBuildDate>Tue, 04 Aug 2026 06:22:55 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/310663.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 17 Nov 2012 20:50:50 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to error: &#x27;X&#x27; was not declared in this scope on Sat, 17 Nov 2012 20:50:50 GMT]]></title><description><![CDATA[<p>Hi, bin neu hier und habe ein Problem. Schreibe gerade ein Programm und bekomme dauernd eine Fehler. Es sind eigentlich mehrere aber erstmal interessiert mich nur der Eine.</p>
<p>Der Code lautet:</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;math.h&gt;
using namespace std;

int main (){
	point *A,*B,*C;
	circle *K1,*K2,*K3;
	double r,r1,r2,r3;
        double x,y;
	//...

		//Punkt A
		cout &lt;&lt; &quot;Bitte x y für A eingeben : &quot;;
		cin &gt;&gt; x &gt;&gt; y;
		A = new point(x,y);

		//Punkt B
		cout &lt;&lt; &quot;Bitte x y für B eingeben : &quot;;
		cin &gt;&gt; x &gt;&gt; y;
		B = new point(x,y);

		//Punkt C
		cout &lt;&lt; &quot;Bitte x y für C eingeben : &quot;;
		cin &gt;&gt; x &gt;&gt; y;
		C = new point(x,y);

	//Radien
	r1 = sqrt( pow( A.getX(),2 ) + pow( A.getY(),2 ) ); 
	r2 = sqrt( pow( B.getX(),2 ) + pow( B.getY(),2 ) ); 
	r3 = sqrt( pow( C.getX(),2 ) + pow( C.getY(),2 ) ); 

	if(r1 &gt; r2 &amp;&amp; r1 &gt; r3){
		r = r1;	
	}

	if(r2 &gt; r1 &amp;&amp; r2 &gt; r3){
		r = r2;
                //
	}
	else{
		r = r3;
	}

	//Hilfskreise
	K1 = new circle(A, r);
	K2 = new circle(B, r);
	K3 = new circle(C, r);

	//...
	delete A;
	delete B;
	delete C;

        return 0;
}
</code></pre>
<p>nun kommt immer:</p>
<pre><code>main.cpp:6:2: error: 'point' was not declared in this scope
main.cpp:6:9: error: 'A' was not declared in this scope
main.cpp:6:12: error: 'B' was not declared in this scope
main.cpp:6:15: error: 'C' was not declared in this scope
main.cpp:7:2: error: 'circle' was not declared in this scope
main.cpp:7:10: error: 'K1' was not declared in this scope
main.cpp:7:14: error: 'K2' was not declared in this scope
main.cpp:7:18: error: 'K3' was not declared in this scope
</code></pre>
<p>Also ich habe schon den Fehler gegooglet, aber meistens bezieht sich der Fehler darauf, dass std fehlt.<br />
point und circle sind Klassen, die sich im selben Verzeichnis befinden. Wenn ich mit gedrückten Strg drauf klicke, springt es in die Klasse.<br />
Ich benutze NetBeans IDE 7.2.1 mit MinGW.</p>
<p>Mache ich was grundsätzlich falsch oder ist das ein IDE/Compiler Problem.</p>
<p>Ich hoffe die Infos reichen und mir kann eine helfen.</p>
<p>Gruß<br />
POC</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2271879</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2271879</guid><dc:creator><![CDATA[powerofcan]]></dc:creator><pubDate>Sat, 17 Nov 2012 20:50:50 GMT</pubDate></item><item><title><![CDATA[Reply to error: &#x27;X&#x27; was not declared in this scope on Sat, 17 Nov 2012 20:56:35 GMT]]></title><description><![CDATA[<p>Es reicht nicht, dass sie sich im gleichen Verzeichnis befinden. Die Header müssen schon mit include in die Übersetzungseinheit eingebunden werden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2271882</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2271882</guid><dc:creator><![CDATA[manni66]]></dc:creator><pubDate>Sat, 17 Nov 2012 20:56:35 GMT</pubDate></item><item><title><![CDATA[Reply to error: &#x27;X&#x27; was not declared in this scope on Sat, 17 Nov 2012 20:57:28 GMT]]></title><description><![CDATA[<blockquote>
<p>point und circle sind Klassen, die sich im selben Verzeichnis befinden</p>
</blockquote>
<p>Das reicht leider nicht. Du musst die Datei(en) auch noch in den Programm per <code>#include</code> einbinden, z.B.</p>
<pre><code>#include &quot;point.h&quot;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2271883</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2271883</guid><dc:creator><![CDATA[Ferris]]></dc:creator><pubDate>Sat, 17 Nov 2012 20:57:28 GMT</pubDate></item><item><title><![CDATA[Reply to error: &#x27;X&#x27; was not declared in this scope on Sun, 18 Nov 2012 00:06:07 GMT]]></title><description><![CDATA[<p>Erst einmal vielen Dank.<br />
Habe noch nie Header erstellt und irgendwie gibt es da oder verschiedene Möglichkeiten, oder ich blicke das noch nicht so ganz.</p>
<p>Ich habe meine Klasse point</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;math.h&gt;
#include &quot;point.h&quot;

class point{
	private:
		double x;
		double y;

	public:
		point(double x, double y){
			this-&gt;x = x;
			this-&gt;y = y;
		}

		double getX(){
			return x;
		}

		double getY(){
			return y;
		}
};
</code></pre>
<p>Nun habe ich versucht eine Header Datei zu erstellen:</p>
<pre><code>#ifndef POINT_H
#define	POINT_H

#include &lt;iostream&gt;
#include &lt;math.h&gt;

double getX();
double getY();

#endif	/* POINT_H */
</code></pre>
<p>Also das kann nicht richtig sein. Sieht auch irgendwie aus, als ob in die Header Datei die Klasse kommt und die Funktionen in der cpp ausgeschrieben werden. Wie sollten die Dateien den aussehen, damit das funktioniert?</p>
<p>Gruß<br />
POC</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2271917</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2271917</guid><dc:creator><![CDATA[powerofcan]]></dc:creator><pubDate>Sun, 18 Nov 2012 00:06:07 GMT</pubDate></item><item><title><![CDATA[Reply to error: &#x27;X&#x27; was not declared in this scope on Sun, 18 Nov 2012 00:19:50 GMT]]></title><description><![CDATA[<p>Das kannst du wie folgt machen (ich habs nicht kompiliert und getestet):</p>
<p>Point.hpp, das Header File:</p>
<pre><code class="language-cpp">#ifndef POINT_HPP
#define POINT_HPP

class Point
{
private:
  double _x, _y;
public:
  Point(double x, double y);
  double get_x() const;
  double get_y() const;
};

#endif
</code></pre>
<p>Point.cpp, die Implementierung:</p>
<pre><code class="language-cpp">#include &quot;Point.hpp&quot;

Point::Point(double x, double y)
  : _x(x), _y(y) {}

double Point::get_x() const { return _x; }
double Point::get_y() const { return _y; }
</code></pre>
<p>Falls du nicht verstehst wofuer das 'const' da ist, dann kannst du das fuers erste ignorieren, funktioniert auch ohne. Wenn du die Syntax bei der Implementierung des Konstruktors nicht verstehst, dann google mal nach &quot;Initialization List&quot;.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2271919</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2271919</guid><dc:creator><![CDATA[icarus2]]></dc:creator><pubDate>Sun, 18 Nov 2012 00:19:50 GMT</pubDate></item><item><title><![CDATA[Reply to error: &#x27;X&#x27; was not declared in this scope on Sun, 18 Nov 2012 00:23:56 GMT]]></title><description><![CDATA[<p><strong>Entweder so (alles inline):</strong></p>
<p>point.h:</p>
<pre><code>// #include &lt;iostream&gt;     Wozu?
// #include &lt;math.h&gt;    1. Wozu? 2. Das heißt cmath! math.h ist C.

class point{
    private:
        double x;
        double y;

    public:
        point(double x, double y): x(x), y(y){} // Nimm lieber eine Initialisierungsliste

        double getX() const{  // const-correctness beachten!
            return x;
        }

        double getY() const{
            return y;
        }
};
</code></pre>
<p>Keine point.cpp</p>
<p><strong>Oder so (nichts inline):</strong></p>
<p>point.h:</p>
<pre><code>// #include &lt;iostream&gt;     Wozu?
// #include &lt;math.h&gt;    1. Wozu? 2. Das heißt cmath! math.h ist C.

class point{
    private:
        double x;
        double y;

    public:
        point(double x, double y);
        double getX() const;

        double getY() const;
};
</code></pre>
<p>Mit point.cpp:</p>
<pre><code>#include &quot;point.h&quot;

point::point(double x, double y): x(x), y(y) { }

double point::getX() const
{
  return x;
}

double point::getY() const
{
  return y;
}
</code></pre>
<p>Oder irgendetwas zwischen diesen beiden Extremen. Solche Einzeiler würde ich eher inline machen.</p>
<p>Alles ungetestet, können Flüchtigkeitsfehler drin sein.</p>
<p>edit: Zu langsam…</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2271920</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2271920</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Sun, 18 Nov 2012 00:23:56 GMT</pubDate></item><item><title><![CDATA[Reply to error: &#x27;X&#x27; was not declared in this scope on Sun, 18 Nov 2012 14:48:39 GMT]]></title><description><![CDATA[<p>Vielen Dank, funktioniert xD.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2272048</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2272048</guid><dc:creator><![CDATA[powerofcan]]></dc:creator><pubDate>Sun, 18 Nov 2012 14:48:39 GMT</pubDate></item></channel></rss>