<?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 oder besser Class]]></title><description><![CDATA[<p>Hallo!<br />
für einen Port habe ich in einem reinen C-Programm immer eine Struct gehabt:</p>
<pre><code class="language-cpp">typedef struct
  {
//INT8U  Start;                        // automatically transmitted by UART-ISR
  INT8U  Source;                       // 0
  INT8U  Destin;                       // 1
  INT16U Index;                        // 2,3
  INT8U  SysStatus;                    // 4
  INT8U  UserStatus;                   // 5
  INT8U  CmdClass;                     // 6
  INT8U  Cmd;                          // 7
  INT16U DataCount;                    // 8,9
  INT8U  Data [PROTO_BUFFER_SIZE];     // 10; [0..DataCount]
//INT8U  CRC;                          // automatically transmitted by UART-ISR
  } PROTO_BufferStruct;
</code></pre>
<p>Jetzt bringe ich das gesamte Programm von C -&gt; C++.<br />
Meine Frage:<br />
Soll ich die Struktur beibehalten und einfach in meine Klasse packen,<br />
oder besser die Struktur zu einer Klasse machen und sie dann instanziieren,<br />
wobei ich die members public lassen wollte?</p>
<p>danke<br />
to</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/126446/struct-oder-besser-class</link><generator>RSS for Node</generator><lastBuildDate>Mon, 24 Aug 2026 17:44:56 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/126446.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 15 Nov 2005 08:42:43 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to struct oder besser Class on Tue, 15 Nov 2005 08:42:43 GMT]]></title><description><![CDATA[<p>Hallo!<br />
für einen Port habe ich in einem reinen C-Programm immer eine Struct gehabt:</p>
<pre><code class="language-cpp">typedef struct
  {
//INT8U  Start;                        // automatically transmitted by UART-ISR
  INT8U  Source;                       // 0
  INT8U  Destin;                       // 1
  INT16U Index;                        // 2,3
  INT8U  SysStatus;                    // 4
  INT8U  UserStatus;                   // 5
  INT8U  CmdClass;                     // 6
  INT8U  Cmd;                          // 7
  INT16U DataCount;                    // 8,9
  INT8U  Data [PROTO_BUFFER_SIZE];     // 10; [0..DataCount]
//INT8U  CRC;                          // automatically transmitted by UART-ISR
  } PROTO_BufferStruct;
</code></pre>
<p>Jetzt bringe ich das gesamte Programm von C -&gt; C++.<br />
Meine Frage:<br />
Soll ich die Struktur beibehalten und einfach in meine Klasse packen,<br />
oder besser die Struktur zu einer Klasse machen und sie dann instanziieren,<br />
wobei ich die members public lassen wollte?</p>
<p>danke<br />
to</p>
]]></description><link>https://www.c-plusplus.net/forum/post/918199</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/918199</guid><dc:creator><![CDATA[Theresa_Orl]]></dc:creator><pubDate>Tue, 15 Nov 2005 08:42:43 GMT</pubDate></item><item><title><![CDATA[Reply to struct oder besser Class on Tue, 15 Nov 2005 08:47:13 GMT]]></title><description><![CDATA[<p>Strukturen in Cpp sind Klassen, bei denen alle Elemente vom Start weg erstmal öffentlich sind. Ansonsten gibt es keinen Unterschied zu class</p>
]]></description><link>https://www.c-plusplus.net/forum/post/918206</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/918206</guid><dc:creator><![CDATA[Pellaeon]]></dc:creator><pubDate>Tue, 15 Nov 2005 08:47:13 GMT</pubDate></item><item><title><![CDATA[Reply to struct oder besser Class on Tue, 15 Nov 2005 08:49:03 GMT]]></title><description><![CDATA[<p>Gut... aber sind dann Strukturen in C++ (so wie hier Designfehler)?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/918208</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/918208</guid><dc:creator><![CDATA[Theresa_Orl]]></dc:creator><pubDate>Tue, 15 Nov 2005 08:49:03 GMT</pubDate></item><item><title><![CDATA[Reply to struct oder besser Class on Tue, 15 Nov 2005 08:50:39 GMT]]></title><description><![CDATA[<p>Nein, sind sie nicht - besonders wenn du mit (alten) C Funktionen arbeitest.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/918210</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/918210</guid><dc:creator><![CDATA[CStoll (off)]]></dc:creator><pubDate>Tue, 15 Nov 2005 08:50:39 GMT</pubDate></item><item><title><![CDATA[Reply to struct oder besser Class on Tue, 15 Nov 2005 08:52:14 GMT]]></title><description><![CDATA[<p>Strukturen sind aus Abwärtskompatibilitätsgründen zu C da.<br />
Die Nutzung ob class oder struct in C++ ist eher semantischer Natur</p>
]]></description><link>https://www.c-plusplus.net/forum/post/918212</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/918212</guid><dc:creator><![CDATA[Pellaeon]]></dc:creator><pubDate>Tue, 15 Nov 2005 08:52:14 GMT</pubDate></item><item><title><![CDATA[Reply to struct oder besser Class on Tue, 15 Nov 2005 08:53:55 GMT]]></title><description><![CDATA[<p>alles klar - danke!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/918215</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/918215</guid><dc:creator><![CDATA[Theresa_Orl]]></dc:creator><pubDate>Tue, 15 Nov 2005 08:53:55 GMT</pubDate></item><item><title><![CDATA[Reply to struct oder besser Class on Tue, 15 Nov 2005 08:56:25 GMT]]></title><description><![CDATA[<p>Wenn du es sauber machen möchtest (und arbeit) Struct zur Klasse machen, Member private deklarieren, Get/Set-Methoden definieren und durch die Funktionen ergänzen, die zu dem Objekt gehören.</p>
<p>Wenn du nur das C-Programm mit dem C++-Compiler übersetzen und durch C++-Code ergänzen willst, würde ich den C-Programmteil so wenig wie mögliche verändern.</p>
<p>Is kein schlechtes Design, is halt C-Code in einem C++-Programm. <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/918218</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/918218</guid><dc:creator><![CDATA[Mathias]]></dc:creator><pubDate>Tue, 15 Nov 2005 08:56:25 GMT</pubDate></item></channel></rss>