<?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[Privates Datenelement erzeugen]]></title><description><![CDATA[<p>Ich mache gerade eine Übungsaufgabe.</p>
<p>Ich muss in einer Klasse ein privates Datenelement Geburtstag date erzeugen<br />
weis jemand wie man sowas macht</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/243359/privates-datenelement-erzeugen</link><generator>RSS for Node</generator><lastBuildDate>Sun, 20 Sep 2026 01:54:00 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/243359.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 15 Jun 2009 20:43:42 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Privates Datenelement erzeugen on Mon, 15 Jun 2009 20:43:42 GMT]]></title><description><![CDATA[<p>Ich mache gerade eine Übungsaufgabe.</p>
<p>Ich muss in einer Klasse ein privates Datenelement Geburtstag date erzeugen<br />
weis jemand wie man sowas macht</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1727226</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1727226</guid><dc:creator><![CDATA[Kleiner Tim]]></dc:creator><pubDate>Mon, 15 Jun 2009 20:43:42 GMT</pubDate></item><item><title><![CDATA[Reply to Privates Datenelement erzeugen on Mon, 15 Jun 2009 20:53:34 GMT]]></title><description><![CDATA[<p>Was hast du schon versucht?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1727230</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1727230</guid><dc:creator><![CDATA[theta]]></dc:creator><pubDate>Mon, 15 Jun 2009 20:53:34 GMT</pubDate></item><item><title><![CDATA[Reply to Privates Datenelement erzeugen on Mon, 15 Jun 2009 20:58:10 GMT]]></title><description><![CDATA[<p>1.1 Implementieren Sie eine Klasse Person mit den privaten Datenelementen name (Typ char-Array der Größe 80)<br />
und born (Typ: Date). Die Datenelemente sollen durch einen Konstruktor mit folgender Parameterliste initialisiert<br />
werden:<br />
Person(const char *pname, int d, int m, int y); // Name, Tag, Monat, Jahr<br />
Außerdem soll eine befreundete Funktion operator&lt;&lt;() zur Verfügung gestellt werden, mit deren Hilfe die Daten<br />
einer Person ausgegeben werden.</p>
<p>Das ist die Aufgabenstellung</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1727232</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1727232</guid><dc:creator><![CDATA[liouiouio]]></dc:creator><pubDate>Mon, 15 Jun 2009 20:58:10 GMT</pubDate></item><item><title><![CDATA[Reply to Privates Datenelement erzeugen on Mon, 15 Jun 2009 20:59:13 GMT]]></title><description><![CDATA[<p>liouiouio schrieb:</p>
<blockquote>
<p>Das ist die Aufgabenstellung</p>
</blockquote>
<p>Das war nicht die Frage.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1727233</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1727233</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Mon, 15 Jun 2009 20:59:13 GMT</pubDate></item><item><title><![CDATA[Reply to Privates Datenelement erzeugen on Mon, 15 Jun 2009 21:05:54 GMT]]></title><description><![CDATA[<p>Ich hab statt Date born 3 private Datentypen (int) genommen</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1727234</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1727234</guid><dc:creator><![CDATA[zfghf]]></dc:creator><pubDate>Mon, 15 Jun 2009 21:05:54 GMT</pubDate></item><item><title><![CDATA[Reply to Privates Datenelement erzeugen on Mon, 15 Jun 2009 21:40:06 GMT]]></title><description><![CDATA[<p>zfghf schrieb:</p>
<blockquote>
<p>Ich hab statt Date born 3 private Datentypen (int) genommen</p>
</blockquote>
<p>3*int != Date<br />
Und es steht halt Date in der Aufgabenstellung.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1727244</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1727244</guid><dc:creator><![CDATA[fhgzf]]></dc:creator><pubDate>Mon, 15 Jun 2009 21:40:06 GMT</pubDate></item><item><title><![CDATA[Reply to Privates Datenelement erzeugen on Tue, 16 Jun 2009 18:48:04 GMT]]></title><description><![CDATA[<p>komm net weiter!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1727822</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1727822</guid><dc:creator><![CDATA[Hans1234]]></dc:creator><pubDate>Tue, 16 Jun 2009 18:48:04 GMT</pubDate></item><item><title><![CDATA[Reply to Privates Datenelement erzeugen on Tue, 16 Jun 2009 19:33:22 GMT]]></title><description><![CDATA[<p>fhgzf schrieb:</p>
<blockquote>
<p>3*int != Date<br />
Und es steht halt Date in der Aufgabenstellung.</p>
</blockquote>
<p>Mag sein, aber in C++ gibt es keinen Date-Datentyp. Entweder die Aufgabe enthält noch mehr (z.B. erstellen einer Date-Klasse oder Vorgabe einer bestimmten Bibliothek...) oder da hat jemand die Aufgaben von einer Sprache in eine Andere übertragen und einiges Übersehen (zumal ich char[80] für Strings auch schon daneben finde - irgendwie kennen Dozenten/Lehrer keinen std::string).</p>
<p>Und der Rest (privates Datenelement erzeugen) ist wiederum so trivial das ich hier nur auf irgendein x-beliebiges Tutorial oder Buch verweise.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1727863</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1727863</guid><dc:creator><![CDATA[asc]]></dc:creator><pubDate>Tue, 16 Jun 2009 19:33:22 GMT</pubDate></item><item><title><![CDATA[Reply to Privates Datenelement erzeugen on Wed, 17 Jun 2009 12:18:47 GMT]]></title><description><![CDATA[<p>class Date<br />
{<br />
private:<br />
int day, month, year;</p>
<p>public:<br />
Date(int d, int m, int y)<br />
{<br />
day = d;<br />
month = m;<br />
year = y;<br />
}<br />
friend ostream &amp;operator&lt;&lt;(ostream &amp;os, const Date &amp;dt);<br />
};<br />
inline ostream &amp;operator&lt;&lt;(ostream &amp;os, const Date &amp;dt)<br />
{<br />
return os &lt;&lt; dt.day &lt;&lt; '.' &lt;&lt; dt.month &lt;&lt; '.' &lt;&lt; dt.year;<br />
}</p>
<p>class Person<br />
{<br />
char name[80];<br />
Date *born;<br />
public:<br />
Person(const char *pname, int d, int m, int y)<br />
{<br />
strcpy(name,pname);<br />
//Date bo(d,m,y);<br />
born = new Date(d,m,y);<br />
}<br />
friend ostream &amp;operator&lt;&lt;(ostream &amp;os, const Person &amp;dt);<br />
};</p>
<p>Hab noch ein wenig was herausgefunden. Ne klasse Date gabs allerdings ohne StandartKonstruktor gehe ich dan richtig in der annahme das ich das ganze dann<br />
als Date *born definiernen muss weil Date born ja ohne Standk nicht geht oder</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1728137</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1728137</guid><dc:creator><![CDATA[Lukaslukas]]></dc:creator><pubDate>Wed, 17 Jun 2009 12:18:47 GMT</pubDate></item><item><title><![CDATA[Reply to Privates Datenelement erzeugen on Wed, 17 Jun 2009 12:52:01 GMT]]></title><description><![CDATA[<p>Lukaslukas schrieb:</p>
<blockquote>
<p>...</p>
</blockquote>
<p>1. Benutze bitte die C/C++ Tags für die Codeformatierung.</p>
<p>Lukaslukas schrieb:</p>
<blockquote>
<p>Hab noch ein wenig was herausgefunden. Ne klasse Date gabs allerdings ohne StandartKonstruktor gehe ich dan richtig in der annahme das ich das ganze dann als Date *born definiernen muss weil Date born ja ohne Standk nicht geht oder</p>
</blockquote>
<p>Da liegst du falsch. Dazu gibt es die Initialisierungsliste.</p>
<pre><code class="language-cpp">class Person
{
    char name[80];
    Date born;
public:
    Person(const char *pname, int d, int m, int y)
    :   born(d,m,y) // Initialisierungsliste
    {
       // Hier existieren die Elemente bereits, und du machst eine
       // Zuweisung, keine Initialisierung.
       //...
    }
...
</code></pre>
<p>Dennoch frage ich mich warum auf die C-Bibliothek und C-Strings zurückgegriffen werden soll.</p>
<p>cu André</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1728159</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1728159</guid><dc:creator><![CDATA[asc]]></dc:creator><pubDate>Wed, 17 Jun 2009 12:52:01 GMT</pubDate></item><item><title><![CDATA[Reply to Privates Datenelement erzeugen on Wed, 17 Jun 2009 13:02:15 GMT]]></title><description><![CDATA[<p>wieder was gelernt danke</p>
<p>mit der String klasse gehts auch</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1728168</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1728168</guid><dc:creator><![CDATA[Ganz ganz]]></dc:creator><pubDate>Wed, 17 Jun 2009 13:02:15 GMT</pubDate></item></channel></rss>