<?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[Compiler-Warnung &amp;quot;non-static data member...&amp;quot; in Klassenheader]]></title><description><![CDATA[<p>Hallo,</p>
<p>beim Kompilieren meines Programms erhalte ich folgende Warnungen, das Programm funktioniert aber ohne Probleme. Trotzdem würde ich die Warnungen natürlich gerne verstehen und auch eliminieren bzw. umgehen.<br />
Es geht um die Anwendung eines Bubblesorts, der aufsteigend sortieren soll. Denke mal, dass das aber relativ egal ist; die Warnungen scheinen ja nichts mit dem Code in den Funktionen zu tun zu haben. Die privaten Variablen werden in den Funktionen dann benutzt.</p>
<pre><code>Bubble.h:4:12: warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11 [enabled by default]
   int size=5;
            ^
Bubble.h:5:23: warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11 [enabled by default]
   int A[5]={5,3,0,-1,2};
                       ^
Bubble.h:5:23: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11 [enabled by default]
</code></pre>
<p>Bubble.h</p>
<pre><code>class Bubble
{
 private:
  int size=5;
  int A[5]={5,3,0,-1,2};
 public:
  Bubble();
  void sort();
  void swap(int);
  void print();
};
</code></pre>
<p>Bubble.cpp</p>
<pre><code>#include &quot;Bubble.h&quot;
#include &lt;iostream&gt;

Bubble::Bubble()
{}

void Bubble::sort()
{
  // Code...
}

void Bubble::swap(int j)
{
  // Code...
}

void Bubble::print()
{
  // Code...
}
</code></pre>
<p>main.cpp</p>
<pre><code>#include &quot;Bubble.h&quot;
#include &lt;iostream&gt;

int main(int argc, char *argv[])
{
  Bubble bubble;
  bubble.sort();
  return 0;
}
</code></pre>
<p>Über Erklärungen würde ich mich freuen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/topic/335450/compiler-warnung-quot-non-static-data-member-quot-in-klassenheader</link><generator>RSS for Node</generator><lastBuildDate>Fri, 24 Apr 2026 12:48:13 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/335450.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 21 Nov 2015 16:44:15 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Compiler-Warnung &amp;quot;non-static data member...&amp;quot; in Klassenheader on Sat, 21 Nov 2015 16:44:40 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>beim Kompilieren meines Programms erhalte ich folgende Warnungen, das Programm funktioniert aber ohne Probleme. Trotzdem würde ich die Warnungen natürlich gerne verstehen und auch eliminieren bzw. umgehen.<br />
Es geht um die Anwendung eines Bubblesorts, der aufsteigend sortieren soll. Denke mal, dass das aber relativ egal ist; die Warnungen scheinen ja nichts mit dem Code in den Funktionen zu tun zu haben. Die privaten Variablen werden in den Funktionen dann benutzt.</p>
<pre><code>Bubble.h:4:12: warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11 [enabled by default]
   int size=5;
            ^
Bubble.h:5:23: warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11 [enabled by default]
   int A[5]={5,3,0,-1,2};
                       ^
Bubble.h:5:23: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11 [enabled by default]
</code></pre>
<p>Bubble.h</p>
<pre><code>class Bubble
{
 private:
  int size=5;
  int A[5]={5,3,0,-1,2};
 public:
  Bubble();
  void sort();
  void swap(int);
  void print();
};
</code></pre>
<p>Bubble.cpp</p>
<pre><code>#include &quot;Bubble.h&quot;
#include &lt;iostream&gt;

Bubble::Bubble()
{}

void Bubble::sort()
{
  // Code...
}

void Bubble::swap(int j)
{
  // Code...
}

void Bubble::print()
{
  // Code...
}
</code></pre>
<p>main.cpp</p>
<pre><code>#include &quot;Bubble.h&quot;
#include &lt;iostream&gt;

int main(int argc, char *argv[])
{
  Bubble bubble;
  bubble.sort();
  return 0;
}
</code></pre>
<p>Über Erklärungen würde ich mich freuen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2476424</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2476424</guid><dc:creator><![CDATA[svloga]]></dc:creator><pubDate>Sat, 21 Nov 2015 16:44:40 GMT</pubDate></item><item><title><![CDATA[Reply to Compiler-Warnung &amp;quot;non-static data member...&amp;quot; in Klassenheader on Sat, 21 Nov 2015 17:06:04 GMT]]></title><description><![CDATA[<p>Die Zuweisung von Klassenmembern direkt bei der Deklaration ist erst seit C++11 erlaubt. Setze einfach mal bei deinen Compilereinstellungen &quot;-std=c++11&quot;.<br />
Wenn du nicht weiß, wie, dann schreib mal, welchen Compiler (bzw. IDE) du benutzt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2476426</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2476426</guid><dc:creator><![CDATA[Th69]]></dc:creator><pubDate>Sat, 21 Nov 2015 17:06:04 GMT</pubDate></item><item><title><![CDATA[Reply to Compiler-Warnung &amp;quot;non-static data member...&amp;quot; in Klassenheader on Sat, 21 Nov 2015 18:03:29 GMT]]></title><description><![CDATA[<p>Stimmt, habe es mit -std=c++11 probiert und es wird ohne Warnungen kompiliert.</p>
<p>Benutze den GNU g++ Compiler 4.8.4 (Ubunutu 14.04), aber hab das ja schon hinbekommen.</p>
<p>Danke für deine Antwort <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2476452</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2476452</guid><dc:creator><![CDATA[svloga]]></dc:creator><pubDate>Sat, 21 Nov 2015 18:03:29 GMT</pubDate></item></channel></rss>