<?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[typedef array an Klassenfunktion übergeben]]></title><description><![CDATA[<p>Hallo allerseits,</p>
<p>ich hab hier mal ne Frage zu typedefs und wie ich dann ein solches array übergeben kann. Ok etwas schlechte Formulierung.....<br />
Naja gut! Also folgender Versuch:</p>
<pre><code class="language-cpp">typedef int MyArryTyp;
typedef MyArryTyp array[1600] MyArry;

void main(void){
	MyArry array;
	DoIt(array);
}

void DoIt(MyArry* pArr){
	int i;
	for(i = 0; i &lt; (sizeof(MyArry) / sizeof(MyArryTyp)); i++){
		pArr[i] = 0; // z.B.
	}
}
</code></pre>
<p>Das klappt ja so wenn alles in der main ist...<br />
Bei mir sieht das ganze jetzt so aus:<br />
- generieren des arrays in der <code>main()</code> (main.cpp)<br />
- array übergeben an Klassenfunktion <code>void myClass::funktion()</code> (myClass.cpp)</p>
<p>wenn ich jetzt das typedef in der main mache, dann kennt meine Klasse dieses type nicht...</p>
<p>Wie mach ich das dann am besten?<br />
Muss nicht unbedingt mit typedef sein, aber das schien mir ganz gut weil man dann später die Größer beliebig änderbar ist ohne was am restlichen Code zu ändern....</p>
<p>MFG</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/260708/typedef-array-an-klassenfunktion-übergeben</link><generator>RSS for Node</generator><lastBuildDate>Mon, 07 Sep 2026 23:44:00 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/260708.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 08 Feb 2010 17:29:00 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to typedef array an Klassenfunktion übergeben on Mon, 08 Feb 2010 17:29:00 GMT]]></title><description><![CDATA[<p>Hallo allerseits,</p>
<p>ich hab hier mal ne Frage zu typedefs und wie ich dann ein solches array übergeben kann. Ok etwas schlechte Formulierung.....<br />
Naja gut! Also folgender Versuch:</p>
<pre><code class="language-cpp">typedef int MyArryTyp;
typedef MyArryTyp array[1600] MyArry;

void main(void){
	MyArry array;
	DoIt(array);
}

void DoIt(MyArry* pArr){
	int i;
	for(i = 0; i &lt; (sizeof(MyArry) / sizeof(MyArryTyp)); i++){
		pArr[i] = 0; // z.B.
	}
}
</code></pre>
<p>Das klappt ja so wenn alles in der main ist...<br />
Bei mir sieht das ganze jetzt so aus:<br />
- generieren des arrays in der <code>main()</code> (main.cpp)<br />
- array übergeben an Klassenfunktion <code>void myClass::funktion()</code> (myClass.cpp)</p>
<p>wenn ich jetzt das typedef in der main mache, dann kennt meine Klasse dieses type nicht...</p>
<p>Wie mach ich das dann am besten?<br />
Muss nicht unbedingt mit typedef sein, aber das schien mir ganz gut weil man dann später die Größer beliebig änderbar ist ohne was am restlichen Code zu ändern....</p>
<p>MFG</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1852583</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1852583</guid><dc:creator><![CDATA[Mufasa]]></dc:creator><pubDate>Mon, 08 Feb 2010 17:29:00 GMT</pubDate></item><item><title><![CDATA[Reply to typedef array an Klassenfunktion übergeben on Mon, 08 Feb 2010 17:35:34 GMT]]></title><description><![CDATA[<p>Meinst du so?</p>
<pre><code class="language-cpp">typedef int datentyp;
typedef datentyp arraytyp[100];

void foo(arraytyp a){};

int main()
{
  arraytyp a;
  foo(a);
}
</code></pre>
<p>Du solltest dir aber vielleicht mal die Sprachmittel von C++ näher angucken: Konstanten, Klassen, Vektoren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1852586</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1852586</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Mon, 08 Feb 2010 17:35:34 GMT</pubDate></item><item><title><![CDATA[Reply to typedef array an Klassenfunktion übergeben on Mon, 08 Feb 2010 18:16:49 GMT]]></title><description><![CDATA[<p>SeppJ schrieb:</p>
<blockquote>
<p>Meinst du so?</p>
<pre><code class="language-cpp">typedef int datentyp;
typedef datentyp arraytyp[100];

void foo(arraytyp a){};

int main()
{
  arraytyp a;
  foo(a);
}
</code></pre>
</blockquote>
<p>Danke erstmal für die schnelle Antwort!</p>
<p>Aber das ist so wieder alles in der main.cpp</p>
<p>ich meinte, dass die aufgerufene Funktion, hier <code>foo()</code> in einer Klasse steht. Das heißt in der main wird aufgerufen <code>myClass.foo(arraytyp a);</code></p>
<p>Wenn das so ist, dann kennt die Klasse den arrytyp nicht und es gibt einen Error.....</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1852619</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1852619</guid><dc:creator><![CDATA[Mufasa]]></dc:creator><pubDate>Mon, 08 Feb 2010 18:16:49 GMT</pubDate></item><item><title><![CDATA[Reply to typedef array an Klassenfunktion übergeben on Mon, 08 Feb 2010 18:26:18 GMT]]></title><description><![CDATA[<p>Pack dein typedef in einen Header, den du immer dort includierst wo du das typedef brauchst</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1852631</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1852631</guid><dc:creator><![CDATA[irgendwer]]></dc:creator><pubDate>Mon, 08 Feb 2010 18:26:18 GMT</pubDate></item><item><title><![CDATA[Reply to typedef array an Klassenfunktion übergeben on Mon, 08 Feb 2010 18:38:12 GMT]]></title><description><![CDATA[<p>irgendwer schrieb:</p>
<blockquote>
<p>Pack dein typedef in einen Header, den du immer dort includierst wo du das typedef brauchst</p>
</blockquote>
<p>Das heißt ich pack meinen typedef in <em>myClass.h</em> ???<br />
So?</p>
<pre><code class="language-cpp">// myClass.h
#pragma once

typedef int datentyp;
typedef datentyp arraytyp[100];

class myClass{
  public:
     void foo(arraytyp);
  private:
     //Attribute ...
};

// myClass.cpp
#include &quot;myClass.h&quot;

myClass::myClass(){
}
void myClass::foo(arraytyp a){
   // Funktionskörper
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1852638</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1852638</guid><dc:creator><![CDATA[Mufasa]]></dc:creator><pubDate>Mon, 08 Feb 2010 18:38:12 GMT</pubDate></item><item><title><![CDATA[Reply to typedef array an Klassenfunktion übergeben on Mon, 08 Feb 2010 19:46:38 GMT]]></title><description><![CDATA[<p>Mufasa schrieb:</p>
<blockquote>
<p>irgendwer schrieb:</p>
<blockquote>
<p>Pack dein typedef in einen Header, den du immer dort includierst wo du das typedef brauchst</p>
</blockquote>
<p>Das heißt ich pack meinen typedef in <em>myClass.h</em> ???<br />
So?</p>
</blockquote>
<p>Geschickterweise könntest du auch sowas wie typedef.h machen, falls die Definition in mehr als einer Datei gebraucht wird.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1852682</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1852682</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Mon, 08 Feb 2010 19:46:38 GMT</pubDate></item></channel></rss>