<?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[zugriff auf struct]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich habe probleme mit dem Zugrif auf Structs. Ich versuche was in OpenGL zuschreiben, ich möchte die Koordinaten, die ich mit der Maus bestimme in einen Vector abspeichern.<br />
Ich also folgendes vorliegen:</p>
<pre><code class="language-cpp">struct point
{
	int x,y;
};

using namespace std;

vector&lt;point&gt; punktliste;

void speichern(int x, int q)
{	
		point punkt = (x,q);
		punktliste.push_back(punkt);
}
</code></pre>
<p>ich ,öchte nun auf meinen Struct zugreifen und die Koordinaten in meinen Vector abpeichern.</p>
<pre><code class="language-cpp">void polyline(GLint button, GLint action, GLint xMouse, GLint yMouse) //Mouse callback prozedur
{
	static point endPt1, endPt2;
	static float x,y;
	struct point a;

	if(button == GLUT_RIGHT_BUTTON &amp;&amp; action == GLUT_DOWN)
		{
			endPt1.x = xMouse;
			endPt1.y = winHeight - yMouse;

			cout&lt;&lt;endPt1.x&lt;&lt;&quot;\n&quot; ;
			cout&lt;&lt;endPt1.y&lt;&lt;&quot;\n&quot;;

			a.x = endPt1.x ;
			a.y = endPt1.y;

			drawLineSegment(endPt1, endPt2);
			speichern(a.x, a.y);
			glFlush();
			drawLine(endPt1, endPt2);
			glFlush();				
	}
	else
</code></pre>
<p>Ich bekomme aber immer die Fehlermeldung:<br />
error C2440: 'initializing' : cannot convert from 'int' to 'struct point'</p>
<p>Kann mir mal jemand sagen was ich falsch mache ?</p>
<p>Grüße</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/162018/zugriff-auf-struct</link><generator>RSS for Node</generator><lastBuildDate>Sat, 12 Sep 2026 02:27:25 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/162018.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 13 Oct 2006 15:03:27 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to zugriff auf struct on Fri, 13 Oct 2006 15:03:27 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich habe probleme mit dem Zugrif auf Structs. Ich versuche was in OpenGL zuschreiben, ich möchte die Koordinaten, die ich mit der Maus bestimme in einen Vector abspeichern.<br />
Ich also folgendes vorliegen:</p>
<pre><code class="language-cpp">struct point
{
	int x,y;
};

using namespace std;

vector&lt;point&gt; punktliste;

void speichern(int x, int q)
{	
		point punkt = (x,q);
		punktliste.push_back(punkt);
}
</code></pre>
<p>ich ,öchte nun auf meinen Struct zugreifen und die Koordinaten in meinen Vector abpeichern.</p>
<pre><code class="language-cpp">void polyline(GLint button, GLint action, GLint xMouse, GLint yMouse) //Mouse callback prozedur
{
	static point endPt1, endPt2;
	static float x,y;
	struct point a;

	if(button == GLUT_RIGHT_BUTTON &amp;&amp; action == GLUT_DOWN)
		{
			endPt1.x = xMouse;
			endPt1.y = winHeight - yMouse;

			cout&lt;&lt;endPt1.x&lt;&lt;&quot;\n&quot; ;
			cout&lt;&lt;endPt1.y&lt;&lt;&quot;\n&quot;;

			a.x = endPt1.x ;
			a.y = endPt1.y;

			drawLineSegment(endPt1, endPt2);
			speichern(a.x, a.y);
			glFlush();
			drawLine(endPt1, endPt2);
			glFlush();				
	}
	else
</code></pre>
<p>Ich bekomme aber immer die Fehlermeldung:<br />
error C2440: 'initializing' : cannot convert from 'int' to 'struct point'</p>
<p>Kann mir mal jemand sagen was ich falsch mache ?</p>
<p>Grüße</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1154198</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1154198</guid><dc:creator><![CDATA[elturco]]></dc:creator><pubDate>Fri, 13 Oct 2006 15:03:27 GMT</pubDate></item><item><title><![CDATA[Reply to zugriff auf struct on Fri, 13 Oct 2006 15:10:05 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>Du hast in speichern die falschen Klammern.<br />
Das hier</p>
<pre><code class="language-cpp">point punkt = (x,q);
</code></pre>
<p>sollte so aussehen</p>
<pre><code class="language-cpp">point punkt = {x,q};
</code></pre>
<p>Noch besser wäre es hier aber, wenn du point einen Konstruktor spendierst der die Initialisierung übernimmt.</p>
<pre><code class="language-cpp">struct point
{
    int x,y;
    point(int x_, int y_) : x(x_), y(y_) {}
};
// dann
void speichern(int x, int q)
{   
    punktliste.push_back(point(x,q));
}
</code></pre>
<p>Die Funktion speichern könnte man jetzt auch gleich ganz weglassen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1154204</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1154204</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Fri, 13 Oct 2006 15:10:05 GMT</pubDate></item><item><title><![CDATA[Reply to zugriff auf struct on Sat, 14 Oct 2006 09:16:20 GMT]]></title><description><![CDATA[<p>Hii Braunstein...</p>
<p>also ich danke Dir erstmal, aber das mit Konstruktor gibt mir andauernd ne Fehlermeldung so dass ich das weggelassen habe, mein Prolem ist nun, ich kann zwar etwas in meinen Vector schreiben, aber ich mein das ist alles andere als Koordinaten.</p>
<p>144055072<br />
144055080</p>
<p>anstelle von (362,176)</p>
<p>kannst Du mir vielleicht sagen warum das so ist ?</p>
<pre><code class="language-cpp">#include &lt;vector&gt;       // STL-vector
  #include &lt;algorithm&gt;	

#include &lt;GL/glut.h&gt;
#include &lt;glu.h&gt;
#include &lt;iostream&gt;

GLsizei winWidth = 700;
GLsizei winHeight = 400;

 static float array[10][10];
 float erste[2];

 bool flag = false;

bool blnAction = false;

class polygon
{
public:
	GLint x,y;

};

struct point
{
	int x,y;
	//point(int x_, int y_) : x(x_), y(y_) {}

}; 
//	punktliste.push_back(punkt);

using namespace std;

vector&lt;point&gt; punktliste;

void speichern(int x, int q)
{
	cout&lt;&lt;&quot;hier    &quot;&lt;&lt;x&lt;&lt;&quot;\n&quot;;
	cout&lt;&lt;&quot;hier    &quot;&lt;&lt;q&lt;&lt;&quot;\n&quot;;

	point punkt = {x,q};

		punktliste.push_back(punkt);		
}

void init()
{
	glClearColor(0.0, 0.0, 1.0, 1.0);  // set Window Color to blue Hintergrundfarbe
	glMatrixMode(GL_PROJECTION);       //Art des Koordinatensystems
	gluOrtho2D(0.0, 200.0, 0.0, 150.0);////Koordinatenverteilung festlegen
                                             //x-&gt; 0.0 ... 200.0                                             //y- &gt; 0.0 ... 150.0
}

void displayFcn(void)
{
	glClear(GL_COLOR_BUFFER_BIT);      //Fenster löschen
	glPointSize(5.0);
	glLineWidth(1.75);

}

void winReshapeFcn(GLint newWidth, GLint newHeight)
{
	glViewport(0,0,newWidth, newHeight);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluOrtho2D(0.0,GLdouble(newWidth),0.0,GLdouble(newHeight));

	winWidth = newWidth;
	winHeight= newHeight;
}

void drawPolygon(polygon endPt1, polygon endPt2)
{
	glBegin(GL_POLYGON);

	glVertex2i(endPt1.x,endPt2.y);
}

void draw()
{

	std::vector&lt;point&gt;::iterator i = punktliste.begin();

	for ( i=punktliste.begin(); i != punktliste.end(); ++i ){

		cout&lt;&lt;(int)i&lt;&lt;&quot;\n&quot;;

	}
}
/*
void draw_polygons()
{
  std::vector&lt;point&gt;::iterator i = polygons.begin();
  while(i != poligons.end())
  {
    glBegin(GL_POLYGON);

    std::vector&lt;line_t&gt;::iterator j = (*i).lines;
    while(j != (*i).lines.end())
    {
       glVertex2i( (*j).from.x, (*j).from.y);
       glVertex2i( (*j).to.x, (*j).to.y);
       ++j;
    }
    glEnd();

    ++i;
  }
}
*/

void drawLineSegment(point endPt1, point endPt2)
{

	glBegin(GL_POINTS);								//Zeichenmodus setzten	
	glVertex2i(endPt1.x, endPt1.y);

	glEnd();	
}

void drawLine(point endPt1, point endPt2)
{

	drawLineSegment(endPt1,endPt2);
	glBegin(GL_LINES);
	glFlush();

	glVertex2i(endPt1.x, endPt1.y);	
	glFlush();

}

void buttonBoxFcn(GLint button, GLint action)
{
	if(button==action)
		exit(0);
	else
		exit(1);
}

void polyline(GLint button, GLint action, GLint xMouse, GLint yMouse) //Mouse callback prozedur
{
	static point endPt1, endPt2;
	static float x,y;
	struct point a;

	if(button == GLUT_RIGHT_BUTTON &amp;&amp; action == GLUT_DOWN)
		{
			endPt1.x = xMouse;
			endPt1.y = winHeight - yMouse;

			cout&lt;&lt;endPt1.x&lt;&lt;&quot;\n&quot; ;
			cout&lt;&lt;endPt1.y&lt;&lt;&quot;\n&quot;;

			a.x = endPt1.x ;
			a.y = endPt1.y;
			draw();

			drawLineSegment(endPt1, endPt2);
			speichern(a.x, a.y);
			glFlush();
			drawLine(endPt1, endPt2);

			glFlush();
			glFlush();

		}
	else 
		if(button == GLUT_LEFT_BUTTON &amp;&amp; action == GLUT_DOWN)

			//draw();
			//draw_polygons();
			//draw_polygons();

			//float *g;
			//float *t;
			//g = &amp;erste[0];
			//t = &amp;erste[1];

			//glVertex2i(g,t);
			//glVertex2iv(erste);
		//	int point[] = {10,20};
		//	glVertex2iv(point);

			glEnd();	
	//bool bInAction = false;
			glFlush();							   //zeichen
}

void main(int argc, char**argv)
{

	glutInit(&amp;argc, argv);                         //initialisierung der GLUT Bibliothek
	glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);   //Initialisierung des Bildschirms(Art des Zwischenspeichers, Farben)
	glutInitWindowPosition(100,100);			   //Positionierung des Fensters
	glutInitWindowSize(winWidth,winHeight);		   //Fenstergröße
	glutCreateWindow(&quot;Draw Interactive Polyline&quot;); //Fenstertitel

	init();
	glutButtonBoxFunc(buttonBoxFcn);
	glutDisplayFunc(displayFcn);				   //Festlegen der Funktion die zum zeichen auf dem Bildschurm verwendet wird
	glutReshapeFunc(winReshapeFcn);
	glutMouseFunc(polyline);					   //Funktion die die Funktion &quot;polyline&quot; aufruft, wenn der Maus betätigt wurde

	glutMainLoop();
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1154469</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1154469</guid><dc:creator><![CDATA[elturco]]></dc:creator><pubDate>Sat, 14 Oct 2006 09:16:20 GMT</pubDate></item><item><title><![CDATA[Reply to zugriff auf struct on Sat, 14 Oct 2006 10:00:37 GMT]]></title><description><![CDATA[<p>Hi elturco,</p>
<p>ich nehme an, dass deine &quot;falsche&quot; Ausgabe hierher kommt:</p>
<blockquote>
<pre><code class="language-cpp">void draw()
{

    std::vector&lt;point&gt;::iterator i = punktliste.begin();

    for ( i=punktliste.begin(); i != punktliste.end(); ++i ){

        cout&lt;&lt;(int)i&lt;&lt;&quot;\n&quot;;

    }
}
</code></pre>
</blockquote>
<p>So kannst du die einzelnen Punkte natürlich nicht ausgeben lassen. <em>punktliste</em> enthält doch <em>points</em>, und ein <em>point</em> besteht aus zwei ints. Du kannst den point nicht einfach auf int casten, bzw, dann entsteht eben genau die Ausgabe, die du da bekommen hast. Du musst die einzelnen Elemente von i (x und y) ausgeben.</p>
<p>Noch was: es ist immer ein bisschen anstrengend, wenn man so ewig lange Listings durchschauen muss - begrenze doch bitte die Code-Ausschnitte auf die wesentlichen Teile.</p>
<p>Grüße</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1154484</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1154484</guid><dc:creator><![CDATA[IvoT]]></dc:creator><pubDate>Sat, 14 Oct 2006 10:00:37 GMT</pubDate></item><item><title><![CDATA[Reply to zugriff auf struct on Sat, 14 Oct 2006 10:06:53 GMT]]></title><description><![CDATA[<p>elturco schrieb:</p>
<blockquote>
<p>...das mit Konstruktor gibt mir andauernd ne Fehlermeldung ...</p>
</blockquote>
<p>Ich vermute, dass das daran liegt, dass Du keinen &quot;Copy-Konstruktor&quot; definiert hast. Solange Du gar keinen Ctor definierst, legt der Compiler für Dich automatisch 3 Funktionen an: &quot;Default-Ctor&quot; (also einer ohne Argumente), Copy-Ctor (der aus einem übergebenen Objekt das eigene &quot;füllt&quot;) und ein operator=() (der genauso arbeitet wie der CpyCtor).</p>
<p>(Einige) Diese(r) Operationen brauchst Du, wenn Du StdContainer (wie &quot;vector&quot;) verwenden willst. Also:<br />
- Entweder diese 3 selbst definieren (ist nicht wirklich schwierig)<br />
- oder gar keinen.</p>
<p>Gruß,</p>
<p>Simon2.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1154490</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1154490</guid><dc:creator><![CDATA[Simon2]]></dc:creator><pubDate>Sat, 14 Oct 2006 10:06:53 GMT</pubDate></item><item><title><![CDATA[Reply to zugriff auf struct on Sat, 14 Oct 2006 10:48:50 GMT]]></title><description><![CDATA[<p>Also mit casten hat es nichts zu tun, dass int habe ich danach davorgestellt... aber das mit dem copy-Konstruktor das kann sein, ich teste das mal, zumal ich im moment ne Fehlermeldun gekomme mit:</p>
<p>error C2552: 'punkt' : non-aggregates cannot be initialized with initializer list</p>
<p>kennt das einer von euch ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1154518</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1154518</guid><dc:creator><![CDATA[elturco]]></dc:creator><pubDate>Sat, 14 Oct 2006 10:48:50 GMT</pubDate></item><item><title><![CDATA[Reply to zugriff auf struct on Sat, 14 Oct 2006 10:55:52 GMT]]></title><description><![CDATA[<p>Das kommt weil du nen Konstruktor hast.<br />
Dann funktioniert sowas wie</p>
<pre><code class="language-cpp">point punkt = {x,y};
</code></pre>
<p>nicht mehr.<br />
Würde imho auch nicht mehr funktionieren sobald die struct Members hätte die private oder protected sind.</p>
<p>Gruß Spacelord</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1154527</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1154527</guid><dc:creator><![CDATA[Spacelord]]></dc:creator><pubDate>Sat, 14 Oct 2006 10:55:52 GMT</pubDate></item><item><title><![CDATA[Reply to zugriff auf struct on Sat, 14 Oct 2006 11:13:17 GMT]]></title><description><![CDATA[<p>elturco schrieb:</p>
<blockquote>
<p>Also mit casten hat es nichts zu tun, dass int habe ich danach davorgestellt...</p>
</blockquote>
<p>Das Casten ist dabei natürlich nicht der eigentliche Fehler. Trotzdem:</p>
<p>du machst sowas:</p>
<pre><code>point p;
cout&lt;&lt; p;
</code></pre>
<p>du willst aber sowas:</p>
<pre><code>point p;
cout&lt;&lt; p.x &lt;&lt; &quot;,&quot; &lt;&lt; p.y;
</code></pre>
<p>Du versuchst, den point _direkt_ auszugeben. Egal, ob du noch castest oder nicht... es funktioniert nicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1154530</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1154530</guid><dc:creator><![CDATA[IvoT]]></dc:creator><pubDate>Sat, 14 Oct 2006 11:13:17 GMT</pubDate></item><item><title><![CDATA[Reply to zugriff auf struct on Sat, 14 Oct 2006 11:14:51 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/6508">@Ivo</a>, danke Dir...</p>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/198">@Spacelord</a>, wie kann ich es denn verhindern, dass er mir diese Fehlermeldung nicht mehr gibt, einfach diese Zeile mit</p>
<pre><code class="language-cpp">point punkt = {x,y};
</code></pre>
<p>entfernen ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1154540</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1154540</guid><dc:creator><![CDATA[elturco]]></dc:creator><pubDate>Sat, 14 Oct 2006 11:14:51 GMT</pubDate></item><item><title><![CDATA[Reply to zugriff auf struct on Sat, 14 Oct 2006 11:18:41 GMT]]></title><description><![CDATA[<p>Indem du den Konstruktor auch benutzt?</p>
<pre><code class="language-cpp">point punkt(x,y);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1154545</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1154545</guid><dc:creator><![CDATA[Spacelord]]></dc:creator><pubDate>Sat, 14 Oct 2006 11:18:41 GMT</pubDate></item><item><title><![CDATA[Reply to zugriff auf struct on Sat, 14 Oct 2006 11:25:51 GMT]]></title><description><![CDATA[<p>Ich komm einfach nicht weiter, jetzt bekomme ich ein Linker fehler :-):-(!6²§&amp;+</p>
<pre><code class="language-cpp">Compiling...
polgon.cpp
Linking...
polgon.obj : error LNK2001: unresolved external symbol &quot;public: __thiscall point::point(void)&quot; (??0point@@QAE@XZ)
Debug/Polygon.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1154551</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1154551</guid><dc:creator><![CDATA[elturco]]></dc:creator><pubDate>Sat, 14 Oct 2006 11:25:51 GMT</pubDate></item><item><title><![CDATA[Reply to zugriff auf struct on Sat, 14 Oct 2006 11:27:48 GMT]]></title><description><![CDATA[<p>Zeig mal den aktuellen Code von struct point.<br />
Der sucht nach der Implementierung eines Konstruktors,der keine Parameter erwartet.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1154553</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1154553</guid><dc:creator><![CDATA[Spacelord]]></dc:creator><pubDate>Sat, 14 Oct 2006 11:27:48 GMT</pubDate></item><item><title><![CDATA[Reply to zugriff auf struct on Sat, 14 Oct 2006 11:30:28 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/198">@Spacelord</a> danke Dir man</p>
<pre><code class="language-cpp">struct point
{
public:
	int x,y;
	point();
	point(int _x, int _y) : x(_x), y(_y) {};

};
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1154558</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1154558</guid><dc:creator><![CDATA[elturco]]></dc:creator><pubDate>Sat, 14 Oct 2006 11:30:28 GMT</pubDate></item><item><title><![CDATA[Reply to zugriff auf struct on Sat, 14 Oct 2006 11:51:01 GMT]]></title><description><![CDATA[<p>Nimm den point() Konstruktor raus und ändere den mit den 2 int Parametern so ab dass dieser als Standardkonstruktor benutzt werden kann.</p>
<pre><code class="language-cpp">struct point
{
public:
    int x,y;
    point(int _x=0, int _y=0) : x(_x), y(_y) {};
};
</code></pre>
<p>Halt genau so wie ich es dir gestern Mittag schon in dem anderen Forum gepostetet habe..... <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1154574</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1154574</guid><dc:creator><![CDATA[Spacelord]]></dc:creator><pubDate>Sat, 14 Oct 2006 11:51:01 GMT</pubDate></item><item><title><![CDATA[Reply to zugriff auf struct on Sat, 14 Oct 2006 11:51:15 GMT]]></title><description><![CDATA[<p>Da bin ich mir jetzt nicht so sicher, aber ich glaube so gehts dann:</p>
<pre><code>...
int x,y;
point() {};
point(int _x, int _y) : x(_x), y(_y) {};
</code></pre>
<p>sinnvoller wäre vielleicht aber auch statt</p>
<pre><code>point() {};
</code></pre>
<p>sowas</p>
<pre><code>point() {x = 0; y = 0;}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1154575</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1154575</guid><dc:creator><![CDATA[IvoT]]></dc:creator><pubDate>Sat, 14 Oct 2006 11:51:15 GMT</pubDate></item><item><title><![CDATA[Reply to zugriff auf struct on Sat, 14 Oct 2006 11:52:33 GMT]]></title><description><![CDATA[<p>Ist im Grunde das gleiche wie auch spacelord geschrieben hat.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1154576</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1154576</guid><dc:creator><![CDATA[IvoT]]></dc:creator><pubDate>Sat, 14 Oct 2006 11:52:33 GMT</pubDate></item><item><title><![CDATA[Reply to zugriff auf struct on Sat, 14 Oct 2006 12:17:39 GMT]]></title><description><![CDATA[<p>Heyy Leute danke euch vielmals, ich habe noch eine ganz kleine Frage, ich bin euch echt sehr dankbar, ich möchte nun, meinen Vector auslesen und einen Polygon zeichnen. Ich habe folgendes geschrieben:</p>
<pre><code class="language-cpp">void draw()
{
	point p;  ??
	std::vector&lt;point&gt;::iterator i = punktliste.begin();

	for ( i=punktliste.begin(); i != punktliste.end(); ++i ){

		cout&lt;&lt;&quot;wert   &quot;&lt;&lt;p.x&lt;&lt;p.y&lt;&lt;&quot;\n&quot;;
	}
}
</code></pre>
<p>das klappt aber nicht so, was mache ich denn hier falsch ? Ok, mein Konstruktor hat 2 Parameter ? vielleicht ist das mein Fehler, muss ich den hier mit zeigern arbeiten ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1154587</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1154587</guid><dc:creator><![CDATA[elturco]]></dc:creator><pubDate>Sat, 14 Oct 2006 12:17:39 GMT</pubDate></item><item><title><![CDATA[Reply to zugriff auf struct on Sat, 14 Oct 2006 12:19:10 GMT]]></title><description><![CDATA[<p>Klar, mit dem was ich geschrieben hab, kann man keine Punkte und Linien zeichen, ich wollte auch nur erstmal auslesen, das mit glVertex und so müsste ich schon hinkriegen...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1154588</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1154588</guid><dc:creator><![CDATA[elturco]]></dc:creator><pubDate>Sat, 14 Oct 2006 12:19:10 GMT</pubDate></item><item><title><![CDATA[Reply to zugriff auf struct on Sat, 14 Oct 2006 12:27:58 GMT]]></title><description><![CDATA[<p>mein code vorhin sollte nur exemplarisch sein.</p>
<p>Der point p ist unnötig, bei dir müsste es natürlich i.x &lt;&lt; i.y sein.<br />
Aber vorsicht, ich habe sowas in Erinnerung, dass man bei Iterators mit Zeigern arbeitet, also vielleciht muss es auch heißen i-&gt;x &lt;&lt; i-&gt;y.<br />
[edit]<br />
Aus meiner Erinnerung... vielleicht sogar so: *i-&gt;x . Ich weiß es aber nicht mehr so genau.<br />
[/edit]</p>
<p>Ansonsten... sowas hier geht auch:</p>
<pre><code class="language-cpp">void draw()
{
    for ( i = 0; i &lt; punktliste.size(); i++ ){

        cout&lt;&lt; &quot;wert   &quot; &lt;&lt; punktliste[i].x &lt;&lt; punktliste[i].y &lt;&lt; &quot;\n&quot;;
    }
}
</code></pre>
<p>Sehe ich aber selten hier im Forum, weiß nicht, ob das verpönt ist und Nachteile hat - würde aber funktionieren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1154591</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1154591</guid><dc:creator><![CDATA[IvoT]]></dc:creator><pubDate>Sat, 14 Oct 2006 12:27:58 GMT</pubDate></item><item><title><![CDATA[Reply to zugriff auf struct on Sat, 14 Oct 2006 12:44:39 GMT]]></title><description><![CDATA[<p>elturco schrieb:</p>
<blockquote>
<p>....das mit glVertex und so müsste ich schon hinkriegen...</p>
</blockquote>
<p>Sei mir nicht böse, aber zum momentanen Zeitpunkt habe ich Zweifel daran.</p>
<p>Gruß Spacelord</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1154601</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1154601</guid><dc:creator><![CDATA[Spacelord]]></dc:creator><pubDate>Sat, 14 Oct 2006 12:44:39 GMT</pubDate></item><item><title><![CDATA[Reply to zugriff auf struct on Sat, 14 Oct 2006 13:18:08 GMT]]></title><description><![CDATA[<p>ja ich bin Dir nicht böse Spacelord, die Aufgabe kam ein wenig plötzlich, konnte mich nicht effizient in die Materie einarbeiten, deshalb schlage ich mich auch hier rum, aber ich danke euch beiden, immerhin habe ich bisher was dazu gelernt von euch...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1154618</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1154618</guid><dc:creator><![CDATA[elturco]]></dc:creator><pubDate>Sat, 14 Oct 2006 13:18:08 GMT</pubDate></item><item><title><![CDATA[Reply to zugriff auf struct on Sun, 15 Oct 2006 16:37:46 GMT]]></title><description><![CDATA[<p>Hiii,</p>
<p>ich möchte euch nochmal was fragen, wenn ich die Polygone zeichnen möchte, bekomme ich nicht alle Linien gezeichnet, sonderen immer den darauf folgenden, ich habe folgendes gemacht einfach:</p>
<pre><code class="language-cpp">void zeichne()
{
	for(int i = 0;i&lt;punktliste.size();i++)
	{
		cout&lt;&lt;&quot;wert   &quot;&lt;&lt;punktliste[i].x&lt;&lt;&quot;   &quot;&lt;&lt;punktliste[i].y&lt;&lt;&quot;\n&quot;;
		glBegin(GL_LINES);
		glVertex2i(punktliste[i].x,punktliste[i].y);	
	}   
}
</code></pre>
<p>Ich möchte jetzt nun so vorgehen, dass ich noch einen struct definiere und die Linien in einen vector abspeichere und danach einfach durchlaufen lassen. Ich mein, findet Ihr es denn Effizient das so zu machen, denn ich möchte die Polygone abspeichern und laden können, und wenn ich 2 - 3 vectoren habe, ist das doch ein wenig kompliziert gemacht oder nicht ?</p>
<p>was meint Ihr ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1155222</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1155222</guid><dc:creator><![CDATA[elturco]]></dc:creator><pubDate>Sun, 15 Oct 2006 16:37:46 GMT</pubDate></item></channel></rss>