<?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[struct an Funktion übergeben.]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich erzeuge dynamisch eine Struktur:</p>
<pre><code class="language-cpp">struct strVokabeln *myVokabel;
   myVokabel = new strVokabeln[iMaxLines];
</code></pre>
<p>diese übergebe ich dann eine Funktion:</p>
<pre><code class="language-cpp">//Prototype:
//void loadVokabeln ( std::ifstream &amp;myFile, strVokabeln *myVocabulum );

loadVokabeln(myFile, myVokabel);

//und dann noch einer Funktion

//Prototype:
//void oneonetraining ( strVokabeln *myVocabulum, int *iMaxLines, int Durchlaeufe);

oneonetraining (myVokabel, &amp;iMaxLines, 20);
</code></pre>
<p>Nun meine Frage, wie kann ich immer mit der einen struct arbeiten. Muss ich sie mir immer von der Funktion als return wert zurück geben lassen oder geht das noch anderes.</p>
<p>Den ich habe gemerkt wenn ich die eine Funktion &quot;loadVokabeln&quot; aufrufe und die struct voll machen ich den inhalt bei der nächsten Funktion oneonetraining (die Ausgabe) nicht mehr habe.</p>
<p>Wie kann ich das Ressourcenschonend lösen?</p>
<p>gruß und shcon mal dank</p>
<p>zyon</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/162397/struct-an-funktion-übergeben</link><generator>RSS for Node</generator><lastBuildDate>Sat, 12 Sep 2026 09:20:00 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/162397.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 18 Oct 2006 08:24:01 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to struct an Funktion übergeben. on Wed, 18 Oct 2006 08:24:01 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich erzeuge dynamisch eine Struktur:</p>
<pre><code class="language-cpp">struct strVokabeln *myVokabel;
   myVokabel = new strVokabeln[iMaxLines];
</code></pre>
<p>diese übergebe ich dann eine Funktion:</p>
<pre><code class="language-cpp">//Prototype:
//void loadVokabeln ( std::ifstream &amp;myFile, strVokabeln *myVocabulum );

loadVokabeln(myFile, myVokabel);

//und dann noch einer Funktion

//Prototype:
//void oneonetraining ( strVokabeln *myVocabulum, int *iMaxLines, int Durchlaeufe);

oneonetraining (myVokabel, &amp;iMaxLines, 20);
</code></pre>
<p>Nun meine Frage, wie kann ich immer mit der einen struct arbeiten. Muss ich sie mir immer von der Funktion als return wert zurück geben lassen oder geht das noch anderes.</p>
<p>Den ich habe gemerkt wenn ich die eine Funktion &quot;loadVokabeln&quot; aufrufe und die struct voll machen ich den inhalt bei der nächsten Funktion oneonetraining (die Ausgabe) nicht mehr habe.</p>
<p>Wie kann ich das Ressourcenschonend lösen?</p>
<p>gruß und shcon mal dank</p>
<p>zyon</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1156806</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1156806</guid><dc:creator><![CDATA[zyon]]></dc:creator><pubDate>Wed, 18 Oct 2006 08:24:01 GMT</pubDate></item><item><title><![CDATA[Reply to struct an Funktion übergeben. on Wed, 18 Oct 2006 08:32:04 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>Du erzeugst mit obigen Aufruf keine Struktur, sondern ein Array der Größe iMaxLines von Strukturen. Du kannst dieses Array eigentlich schon so übergeben. Wo erzeugst du dieses Array denn? Vielleicht zeigst du mal ein wenig mehr Code. Woher weiß loadVokabeln wie groß das Array maximal sein darf? Du übergibst da iMaxLines nicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1156821</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1156821</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Wed, 18 Oct 2006 08:32:04 GMT</pubDate></item><item><title><![CDATA[Reply to struct an Funktion übergeben. on Wed, 18 Oct 2006 08:33:51 GMT]]></title><description><![CDATA[<p>Der Code, soweit du ihn uns gezeigt hast, ist korrekt. Dein Problem muß an anderer Stelle liegen.</p>
<p>Nackte Arrays zu verwenden ist übrigens unklug. Dafür sollte man lieber einen std::vector nehmen. Die sind einfacher zu handhaben (würde fast wetten, daß dir der Fehler, der dir hier passiert ist, mit einem std::vector nicht unterlaufen wäre).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1156824</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1156824</guid><dc:creator><![CDATA[Z2]]></dc:creator><pubDate>Wed, 18 Oct 2006 08:33:51 GMT</pubDate></item><item><title><![CDATA[Reply to struct an Funktion übergeben. on Wed, 18 Oct 2006 08:44:03 GMT]]></title><description><![CDATA[<p>Ich weiß worauf du hinaus willst.</p>
<p>Hier mal der Code:</p>
<p><strong>main.cpp</strong></p>
<pre><code class="language-cpp">#include &quot;Functions.h&quot;
//---------------------------------------------------------------------------
using namespace std;

int main ( )
{
   int iMaxLines;

   ifstream myFile;
   myFile.open (&quot;C:\\test.txt&quot;);

   if(!myFile){
      cout &lt;&lt; &quot;Fehler beim Oeffnen der Datei!\n&quot;;
      exit(1);
   }

   iMaxLines = getFileLines( myFile );
   struct strVokabeln *myVokabel;
   myVokabel = new strVokabeln[iMaxLines];

   loadVokabeln(myFile, myVokabel);

   oneonetraining (myVokabel, &amp;iMaxLines, 20);

   myFile.close();
   delete [] myVokabel;
   cin.get();
   return 0;
}
</code></pre>
<p><strong>Functions.h</strong></p>
<pre><code class="language-cpp">//---------------------------------------------------------------------------
#include &lt;iostream&gt;
#include &lt;fstream&gt;
#include &lt;string&gt;
//---------------------------------------------------------------------------

struct strVokabeln
{
   std::string sDeutsch;
   std::string sEnglisch;
};

int getFileLines ( std::ifstream &amp;myFile );
void loadVokabeln ( std::ifstream &amp;myFile, strVokabeln *myVocabulum );
void oneonetraining ( strVokabeln *myVocabulum, int *iMaxLines, int Durchlaeufe);
int getRandomNumber ( int iMaxMumber );
</code></pre>
<p><strong>Functions.cpp</strong></p>
<pre><code class="language-cpp">#include &quot;Functions.h&quot;

using namespace std;

int getFileLines(ifstream &amp;myFile )
{
   int iCount=0;
   if( myFile )
   {
      string ligne;
      while( getline( myFile, ligne ) )
      {
         iCount++;
      }

   }
   return iCount;
}

void loadVokabeln(ifstream &amp;myFile, strVokabeln *myVocabulum )
{
   string sLine;
   int i=0;
   while ( myFile.good() ) {
       getline(myFile, sLine);
       string::size_type pos = sLine.find(&quot;:&quot;);

       myVocabulum[i].sDeutsch = sLine.substr(0,pos-1);
       myVocabulum[i].sEnglisch = sLine.substr(pos+1,sLine.length());

       ++i;
   }
}

int getRandomNumber(int iMaxMumber )
{
   srand( (unsigned) time(NULL) ) ;
   return(1 + ( rand() % iMaxMumber ));
}

void oneonetraining ( strVokabeln *myVocabulum, int *iMaxLines, int Durchlaeufe)
{
   int iRand = 0;
   string sWordCheck;
   for (int i=0; i &lt;= Durchlaeufe;i++)
   {
      iRand = getRandomNumber(*iMaxLines);
      cout &lt;&lt; myVocabulum[iRand].sDeutsch &lt;&lt; &quot; : &quot;;
      cin &gt;&gt; sWordCheck;

      if(sWordCheck  == myVocabulum[iRand].sEnglisch )
      {
      cout &lt;&lt; &quot;\n RICHTIG &quot; &lt;&lt; endl;
      }
      else
      {
         cout &lt;&lt; &quot;\n FALSCH &quot; &lt;&lt; endl;
      }
   }
}
</code></pre>
<p>Z2 schrieb:</p>
<blockquote>
<p>Der Code, soweit du ihn uns gezeigt hast, ist korrekt. Dein Problem muß an anderer Stelle liegen.</p>
<p>Nackte Arrays zu verwenden ist übrigens unklug. Dafür sollte man lieber einen std::vector nehmen. Die sind einfacher zu handhaben (würde fast wetten, daß dir der Fehler, der dir hier passiert ist, mit einem std::vector nicht unterlaufen wäre).</p>
</blockquote>
<p>Ich habe es gestern mit eine map gemacht. Wollte mich aber bisschen mit ner struct schullen. Wenn diese Version läuft werde ich es sicher mal mit einem vector versuchen. Aber erst mal will ich es auch so lösen.</p>
<p>Gruß</p>
<p>zyon</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1156828</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1156828</guid><dc:creator><![CDATA[zyon]]></dc:creator><pubDate>Wed, 18 Oct 2006 08:44:03 GMT</pubDate></item><item><title><![CDATA[Reply to struct an Funktion übergeben. on Wed, 18 Oct 2006 08:43:49 GMT]]></title><description><![CDATA[<p>Wenn du schonend arbeiten möchtest arbeite mit Zeigern und Referenzen bei größeren Strukturen.<br />
Das Einsparen eines Rückgabewertes oder Parameters wirkt sich meist nicht spührbar aus. (Jedenfalls wenn man nicht gerade auf Microcontrollern rumhampelt bei denen es auf jedes Bit ankommt oder man wirklich extrem schnellen Code schreiben muss.)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1156836</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1156836</guid><dc:creator><![CDATA[Mathias]]></dc:creator><pubDate>Wed, 18 Oct 2006 08:43:49 GMT</pubDate></item><item><title><![CDATA[Reply to struct an Funktion übergeben. on Wed, 18 Oct 2006 08:51:36 GMT]]></title><description><![CDATA[<p>Wie schon gesagt, solltest du in loadVokabeln die Maximallänge mit übergeben. Außerdem ließt deine whlie-Schleif einen Eintrag zuviel. Ich würde es mal so machen.</p>
<pre><code class="language-cpp">void loadVokabeln(ifstream &amp;myFile, strVokabeln *myVocabulum, int size )
{
   string sLine;
   int i=0;
   while ( myFile.good() &amp;&amp; i&lt;size ) {
       getline(myFile, sLine);
       string::size_type pos = sLine.find(&quot;:&quot;);
       if( myFile.good() &amp;&amp; pos != string::npos)
       {
          myVocabulum[i].sDeutsch = sLine.substr(0,pos-1);
          myVocabulum[i].sEnglisch = sLine.substr(pos+1,sLine.length());
          ++i;
       }  
   }
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1156841</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1156841</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Wed, 18 Oct 2006 08:51:36 GMT</pubDate></item><item><title><![CDATA[Reply to struct an Funktion übergeben. on Wed, 18 Oct 2006 09:09:13 GMT]]></title><description><![CDATA[<p>Also wenn du schon mit C++ arbeitest dann würde ich auch objektorientiert programmieren und nicht funktional.<br />
Eine schöne Klasse für die Vokabeln ergäbe z.B. einen gewissen Sinn.<br />
Ansonsten programmierst du ein Mischmasch aus C und C++ und dies ist kein sonderlich guter Programmierstiel.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1156861</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1156861</guid><dc:creator><![CDATA[Mathias]]></dc:creator><pubDate>Wed, 18 Oct 2006 09:09:13 GMT</pubDate></item><item><title><![CDATA[Reply to struct an Funktion übergeben. on Wed, 18 Oct 2006 10:03:08 GMT]]></title><description><![CDATA[<p>ganz komisch habe grade fest gestellt das er mir narnicht mehr in die<br />
while schleife will:</p>
<pre><code class="language-cpp">while ( myFile.good() &amp;&amp; i &lt; iMaxLines) {
</code></pre>
<p>so auch nicht:</p>
<pre><code class="language-cpp">while ( myFile.good()) {
</code></pre>
<p>ganz komisch.</p>
<p>Dieses Problem tritte auf weill ich zuvor dieses machen:</p>
<pre><code class="language-cpp">iMaxLines = getFileLines( myFile );
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1156862</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1156862</guid><dc:creator><![CDATA[zyon]]></dc:creator><pubDate>Wed, 18 Oct 2006 10:03:08 GMT</pubDate></item><item><title><![CDATA[Reply to struct an Funktion übergeben. on Wed, 18 Oct 2006 10:04:56 GMT]]></title><description><![CDATA[<p>Muss ich myFile wirde wie wieder Freigeben oder sowas in der art?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1156930</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1156930</guid><dc:creator><![CDATA[zyon]]></dc:creator><pubDate>Wed, 18 Oct 2006 10:04:56 GMT</pubDate></item><item><title><![CDATA[Reply to struct an Funktion übergeben. on Wed, 18 Oct 2006 10:11:50 GMT]]></title><description><![CDATA[<p>probiers ma mit myFile.close();</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1156935</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1156935</guid><dc:creator><![CDATA[EXDW]]></dc:creator><pubDate>Wed, 18 Oct 2006 10:11:50 GMT</pubDate></item><item><title><![CDATA[Reply to struct an Funktion übergeben. on Wed, 18 Oct 2006 10:12:25 GMT]]></title><description><![CDATA[<p>Ja, mußt du - C++ setzt die Fehlerflags des Files nicht wieder zurück (d.h. nach dem getFileLines() Aufruf steht der Stream am Ende der Datei (dagegen hilft seekg()) und hat das eofbit gesetzt (kannst du mit clear() wieder zurücksetzen).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1156936</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1156936</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Wed, 18 Oct 2006 10:12:25 GMT</pubDate></item><item><title><![CDATA[Reply to struct an Funktion übergeben. on Wed, 18 Oct 2006 10:12:47 GMT]]></title><description><![CDATA[<p>Mr Evil schrieb:</p>
<blockquote>
<p>probiers ma mit myFile.close();</p>
</blockquote>
<p>ich will es ja nicht schliessen.</p>
<p>ich ahbe es schon versucht indem ich den Poiter wieder am anfang gesetzt habe:</p>
<p>myFile.seekg (0, ios::beg);</p>
<p>geht leider auch nicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1156937</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1156937</guid><dc:creator><![CDATA[zyon]]></dc:creator><pubDate>Wed, 18 Oct 2006 10:12:47 GMT</pubDate></item><item><title><![CDATA[Reply to struct an Funktion übergeben. on Wed, 18 Oct 2006 10:15:38 GMT]]></title><description><![CDATA[<p>Lösung:</p>
<pre><code class="language-cpp">myFile.clear();
   myFile.seekg (0, ios::beg);
</code></pre>
<p>besten dnak CStoll. haber es halt nur amanfang gesetzt ohne das eofbit weg zu machen.</p>
<p>Danke</p>
<p>gruß</p>
<p>zyon</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1156940</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1156940</guid><dc:creator><![CDATA[zyon]]></dc:creator><pubDate>Wed, 18 Oct 2006 10:15:38 GMT</pubDate></item><item><title><![CDATA[Reply to struct an Funktion übergeben. on Thu, 19 Oct 2006 09:39:14 GMT]]></title><description><![CDATA[<p>Z2 schrieb:</p>
<blockquote>
<p>Nackte Arrays zu verwenden ist übrigens unklug. Dafür sollte man lieber einen std::vector nehmen. Die sind einfacher zu handhaben</p>
</blockquote>
<p>Irgendwie weiß icht nicht wie meine struct:</p>
<pre><code class="language-cpp">struct strVokabeln
{
   std::string sDeutsch;
   std::string sEnglisch;
};

struct strVokabeln *myVokabel;
myVokabel = new strVokabeln[iMaxLines];
</code></pre>
<p>als vector aussehen soll. Sprich ich brauch 2 vectoren.. oder? Kann mir da jemand helfen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1157501</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1157501</guid><dc:creator><![CDATA[zyon]]></dc:creator><pubDate>Thu, 19 Oct 2006 09:39:14 GMT</pubDate></item><item><title><![CDATA[Reply to struct an Funktion übergeben. on Thu, 19 Oct 2006 09:40:33 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">#include &lt;vector&gt;

std::vector&lt;strVokablen&gt; myVokabel;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1157506</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1157506</guid><dc:creator><![CDATA[GPC]]></dc:creator><pubDate>Thu, 19 Oct 2006 09:40:33 GMT</pubDate></item><item><title><![CDATA[Reply to struct an Funktion übergeben. on Thu, 19 Oct 2006 09:44:17 GMT]]></title><description><![CDATA[<p>Nein, du brauchst nur einen vector:</p>
<pre><code class="language-cpp">struct strVokabeln
{
   std::string sDeutsch;
   std::string sEnglisch;
};

std::vector&lt;strVokabeln&gt; Woerterbuch;
</code></pre>
<p>jetzt kannst du mit push_back() neue Wörter einfügen, die Größe per resize() anpassen, über []-Operator auf einzelne Elemente zugreifen etc.</p>
<p>(im Magazin findest du den Artikel &quot;Aufbau der STL 1&quot;, dort solltest du mal reinlesen)</p>
<p>PS: Als Bonus könntest du deinem struct noch einen Konstruktor und Stream-Operatoren verpassen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1157509</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1157509</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Thu, 19 Oct 2006 09:44:17 GMT</pubDate></item><item><title><![CDATA[Reply to struct an Funktion übergeben. on Thu, 19 Oct 2006 10:03:45 GMT]]></title><description><![CDATA[<p>Zugriff wird wohl so gehen.</p>
<pre><code class="language-cpp">iMaxLines = getFileLines( myFile );
   vector &lt; strVokabeln &gt; Woerterbuch;
   Woerterbuch.resize(iMaxLines);
   Woerterbuch[1].sDeutsch
</code></pre>
<p>Das ich mit push_back() reinschreiben kann ist mir auch klar. Aber wie unterscheid ich das dann in die einzelnen Felder (sDeutsch,sEnglisch)?</p>
<p>CStoll schrieb:</p>
<blockquote>
<p>PS: Als Bonus könntest du deinem struct noch einen Konstruktor und Stream-Operatoren verpassen.</p>
</blockquote>
<p>?</p>
<p>Besten Dank</p>
<p>CStoll</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1157515</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1157515</guid><dc:creator><![CDATA[zyon]]></dc:creator><pubDate>Thu, 19 Oct 2006 10:03:45 GMT</pubDate></item><item><title><![CDATA[Reply to struct an Funktion übergeben. on Thu, 19 Oct 2006 10:15:52 GMT]]></title><description><![CDATA[<p>zyon schrieb:</p>
<blockquote>
<p>Das ich mit push_back() reinschreiben kann ist mir auch klar. Aber wie unterscheid ich das dann in die einzelnen Felder (sDeutsch,sEnglisch)?</p>
</blockquote>
<p>Wie du es oben schon gemacht hast: &quot;Woerterbuch[i].sDeutsch&quot; für den Deutsch-Teil, &quot;Woerterbuch[i].sEnglisch&quot; für den Englisch-Teil der i-ten Vokabel.</p>
<blockquote>
<p>CStoll schrieb:</p>
<blockquote>
<p>PS: Als Bonus könntest du deinem struct noch einen Konstruktor und Stream-Operatoren verpassen.</p>
</blockquote>
<p>?</p>
</blockquote>
<p>Der Konstruktor ist recht nützlich, um dir Schreibarbeit zu ersparen, damit kannst du statt</p>
<pre><code class="language-cpp">strVokabeln vok;
vok.sDeutsch = &quot;Hund&quot;;
vok.sEnglisch = &quot;dog&quot;;
Woerterbuch.push_back(vok);
</code></pre>
<p>einfach alles zusammenfassen zu:</p>
<pre><code class="language-cpp">Worterbuch.push_back(strVokabeln(&quot;Hund&quot;,&quot;dog&quot;);
</code></pre>
<p>(außerdem finde ich, daß eine Klasse mit Konstruktoren leichter zu handeln ist)</p>
<p>Stream-Operatoren kannst du definieren, um eine Vokabel über IO-Streams eingeben zu können (ist aber nicht unbedingt erforderlich)</p>
<p>PS: Ein Vorteil von vector&lt;&gt; ist, daß er mitwachsen kann - du mußt also nicht die Größe im Voraus berechnen:</p>
<pre><code class="language-cpp">string zeile;
while(getline(myFile,zeile))
{
  size_t trenn = zeile.find(' ');
  Worterbuch.push_back(strVokabeln(zeile.substr(0,trenn),zeile.substr(trenn+1)));
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1157525</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1157525</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Thu, 19 Oct 2006 10:15:52 GMT</pubDate></item><item><title><![CDATA[Reply to struct an Funktion übergeben. on Thu, 19 Oct 2006 10:39:40 GMT]]></title><description><![CDATA[<blockquote>
<p>CStoll schrieb:</p>
<blockquote>
<p>PS: Als Bonus könntest du deinem struct noch einen Konstruktor und Stream-Operatoren verpassen.</p>
</blockquote>
<p>?<br />
Der Konstruktor ist recht nützlich, um dir Schreibarbeit zu ersparen, damit kannst du statt</p>
</blockquote>
<p>Finde das ganze sehr nett, aber wie kann ich den einen Konstruktor eine struct zuweissen? Versehe das mit dem Konstruktor nicht so ganz.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1157541</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1157541</guid><dc:creator><![CDATA[zyon]]></dc:creator><pubDate>Thu, 19 Oct 2006 10:39:40 GMT</pubDate></item><item><title><![CDATA[Reply to struct an Funktion übergeben. on Thu, 19 Oct 2006 10:44:15 GMT]]></title><description><![CDATA[<p>Eine struct ist auch nur eine class, bei der alle Elemente auf public gesetzt sind. Also kann sie genau wie eine class Memberfunktionen und Konstruktoren/Destruktoren erhalten. In deinem Fall sieht das etwa so aus:</p>
<pre><code class="language-cpp">struct strVokabeln
{
  string sDeutsch;
  string sEnglisch;

  strVokabeln(const string&amp; de,const string&amp; en) : sDeutsch(de),sEnglisch(en) {}
};
</code></pre>
<p>(PS: Und ich empfehle dir ein Buch über die Grundlagen von C++)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1157544</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1157544</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Thu, 19 Oct 2006 10:44:15 GMT</pubDate></item></channel></rss>