<?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[Objekt &amp;quot;einfach&amp;quot; durch Stringvergleiche initialisieren]]></title><description><![CDATA[<p>Guten Tag,</p>
<p>ich habe eine Klasse, die hat verschiedene Attribute. Z.B. so:</p>
<pre><code class="language-cpp">class B {
public:
int wert1, hallo, DiesUndDas;
};

class A {
public:
B arrB[20];
};
</code></pre>
<p>Eine Instanz von A (z.B. <strong>gA</strong>) wird jetzt durch Auslesen einer ini-Datei initialisiert. In der Inidatei steht z.B.</p>
<pre><code>[B17]
hallo = 99
DiesUndDas = 1234
</code></pre>
<p>Bedeutet</p>
<pre><code class="language-cpp">gA.arrB[17].hallo = 99;
gA.arrB[17].DiesUndDas = 1234;
</code></pre>
<p>Da für <em>wert1</em> jetzt kein Eintrag vorhanden war, bleibt der <em>wert1</em> jetzt halt unverändert. Meine Frage wäre jetzt, ob das Zuweisen nicht einfacher geht als in einer riesigen Abfrage:</p>
<pre><code class="language-cpp">if(key == &quot;hallo&quot;) {
     gA.arrB[id].hallo = value;
} else if(key == &quot;DiesUndDas&quot; ) {
     gA.arrB[id].DiesUndDas = value;
} else if(key == &quot;wert1&quot;) {
     gA.arrB[id].wert1= value;
} else if { // usw.

} else {
  // Fehler
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/309220/objekt-quot-einfach-quot-durch-stringvergleiche-initialisieren</link><generator>RSS for Node</generator><lastBuildDate>Wed, 05 Aug 2026 12:09:27 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/309220.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 17 Oct 2012 12:59:53 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Objekt &amp;quot;einfach&amp;quot; durch Stringvergleiche initialisieren on Wed, 17 Oct 2012 12:59:53 GMT]]></title><description><![CDATA[<p>Guten Tag,</p>
<p>ich habe eine Klasse, die hat verschiedene Attribute. Z.B. so:</p>
<pre><code class="language-cpp">class B {
public:
int wert1, hallo, DiesUndDas;
};

class A {
public:
B arrB[20];
};
</code></pre>
<p>Eine Instanz von A (z.B. <strong>gA</strong>) wird jetzt durch Auslesen einer ini-Datei initialisiert. In der Inidatei steht z.B.</p>
<pre><code>[B17]
hallo = 99
DiesUndDas = 1234
</code></pre>
<p>Bedeutet</p>
<pre><code class="language-cpp">gA.arrB[17].hallo = 99;
gA.arrB[17].DiesUndDas = 1234;
</code></pre>
<p>Da für <em>wert1</em> jetzt kein Eintrag vorhanden war, bleibt der <em>wert1</em> jetzt halt unverändert. Meine Frage wäre jetzt, ob das Zuweisen nicht einfacher geht als in einer riesigen Abfrage:</p>
<pre><code class="language-cpp">if(key == &quot;hallo&quot;) {
     gA.arrB[id].hallo = value;
} else if(key == &quot;DiesUndDas&quot; ) {
     gA.arrB[id].DiesUndDas = value;
} else if(key == &quot;wert1&quot;) {
     gA.arrB[id].wert1= value;
} else if { // usw.

} else {
  // Fehler
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2261338</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2261338</guid><dc:creator><![CDATA[VolumeDown]]></dc:creator><pubDate>Wed, 17 Oct 2012 12:59:53 GMT</pubDate></item><item><title><![CDATA[Reply to Objekt &amp;quot;einfach&amp;quot; durch Stringvergleiche initialisieren on Wed, 17 Oct 2012 13:17:33 GMT]]></title><description><![CDATA[<p>Schau dir ggf. mal Boost.PropertyTree an: <a href="http://www.boost.org/doc/libs/1_51_0/doc/html/property_tree.html#boost_propertytree.intro" rel="nofollow">http://www.boost.org/doc/libs/1_51_0/doc/html/property_tree.html#boost_propertytree.intro</a></p>
<p>da ist auch ein ini-parser dabei <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2261349</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2261349</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Wed, 17 Oct 2012 13:17:33 GMT</pubDate></item><item><title><![CDATA[Reply to Objekt &amp;quot;einfach&amp;quot; durch Stringvergleiche initialisieren on Wed, 17 Oct 2012 13:27:35 GMT]]></title><description><![CDATA[<p>und wenn du boost nicht verwenden möchtest, such einfach nach beiträgen von werner salomon und ini parser. dann solltest du auch was finden</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2261355</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2261355</guid><dc:creator><![CDATA[vario-500]]></dc:creator><pubDate>Wed, 17 Oct 2012 13:27:35 GMT</pubDate></item></channel></rss>