<?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[[gelöst]valarray als member variable in Klasse]]></title><description><![CDATA[<p>Hallo,<br />
ich habe ein Problem damit einen valarray in einer Klasse als Klassenvariable zu deklarieren.<br />
Im folgenden steht der Code, der eine Idee davon geben soll, was ich haben möchte:</p>
<pre><code class="language-cpp">#include&lt;valarray&gt;
#include&lt;iostream&gt;
using namespace std;

class testclass{
   public:
   valarray&lt;int&gt; testarray( 4 );
   testclass(){
   }   
};
int main ( void ){
   testclass Class;
   Class.testarray[2] = 3;
}
</code></pre>
<p>Dieser Code kompiliert noch nicht einmal.<br />
Fehler:</p>
<pre><code>test.cpp:7: error: expected identifier before numeric constant
test.cpp:7: error: expected ‘,’ or ‘...’ before numeric constant
test.cpp: In function ‘int main()’:
test.cpp:13: error: invalid types ‘&lt;unresolved overloaded function type&gt;[int]’ for array subscript
</code></pre>
<p>Prinzipiell würde ich die Länge des arrays gerne im Konstruktor bestimmen.<br />
Wenn mir jemand weiterhelfen könnte wäre das Klasse.<br />
Gruß<br />
J.Bourne</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/266805/gelöst-valarray-als-member-variable-in-klasse</link><generator>RSS for Node</generator><lastBuildDate>Wed, 02 Sep 2026 19:55:11 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/266805.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 14 May 2010 17:18:09 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [gelöst]valarray als member variable in Klasse on Fri, 14 May 2010 19:06:26 GMT]]></title><description><![CDATA[<p>Hallo,<br />
ich habe ein Problem damit einen valarray in einer Klasse als Klassenvariable zu deklarieren.<br />
Im folgenden steht der Code, der eine Idee davon geben soll, was ich haben möchte:</p>
<pre><code class="language-cpp">#include&lt;valarray&gt;
#include&lt;iostream&gt;
using namespace std;

class testclass{
   public:
   valarray&lt;int&gt; testarray( 4 );
   testclass(){
   }   
};
int main ( void ){
   testclass Class;
   Class.testarray[2] = 3;
}
</code></pre>
<p>Dieser Code kompiliert noch nicht einmal.<br />
Fehler:</p>
<pre><code>test.cpp:7: error: expected identifier before numeric constant
test.cpp:7: error: expected ‘,’ or ‘...’ before numeric constant
test.cpp: In function ‘int main()’:
test.cpp:13: error: invalid types ‘&lt;unresolved overloaded function type&gt;[int]’ for array subscript
</code></pre>
<p>Prinzipiell würde ich die Länge des arrays gerne im Konstruktor bestimmen.<br />
Wenn mir jemand weiterhelfen könnte wäre das Klasse.<br />
Gruß<br />
J.Bourne</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1897202</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1897202</guid><dc:creator><![CDATA[J.Bourne]]></dc:creator><pubDate>Fri, 14 May 2010 19:06:26 GMT</pubDate></item><item><title><![CDATA[Reply to [gelöst]valarray als member variable in Klasse on Fri, 14 May 2010 17:25:33 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">valarray&lt;int&gt; testarray( 4 );
</code></pre>
<p>Das ist kein gültiges C++. Innerhalb der Klassendefinition dürfen Variablen nur deklariert werden.</p>
<p>Zur Initialisierung musst du den Konstruktor benutzen, genauer gesagt dessen Initialisierungsliste.</p>
<pre><code class="language-cpp">testclass() : testarray(4) {}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1897208</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1897208</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Fri, 14 May 2010 17:25:33 GMT</pubDate></item><item><title><![CDATA[Reply to [gelöst]valarray als member variable in Klasse on Fri, 14 May 2010 19:05:45 GMT]]></title><description><![CDATA[<p>Vielen Dank für den Hinweis!<br />
Es funktioniert nun!<br />
Gruß<br />
J.Bourne</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1897274</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1897274</guid><dc:creator><![CDATA[J.Bourne]]></dc:creator><pubDate>Fri, 14 May 2010 19:05:45 GMT</pubDate></item></channel></rss>