Page 1 of 1

warning non-static data member

Posted: Sun Oct 20, 2013 6:37 pm
by borodadada
D:/c++/2/2/main.cpp:17:22: warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11 [enabled by default]

Code: Select all

class Class_windows_function
{
  private:

		int test_counter = 0;
		
  public:

		
		int counter_add(int number) 		
			{
				test_counter = test_counter+number;
				return test_counter;
			}
  
  protected:

};
What's wrong? Why do I get? I can not locate a variable inside the method, since it must extend their.

Re: warning non-static data member

Posted: Sun Oct 20, 2013 6:42 pm
by eranif
This type of questions are not really related to codelite.
It is the _compiler_ that complains about it _not_ codelite

in short:
You can not initialize static members within the class declaration, unless you have enabled C++11 features (the warning gives you the exact flags to add to the compiler)

Eran

Re: warning non-static data member

Posted: Sun Oct 20, 2013 6:57 pm
by borodadada
-std=gnu++11
Image
thank you Eran, work.
Image