warning non-static data member

CodeLite installation/troubleshooting forum
borodadada
CodeLite Enthusiast
Posts: 22
Joined: Wed Oct 16, 2013 4:20 pm
Genuine User: Yes
IDE Question: c++
Contact:

warning non-static data member

Post 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.
User avatar
eranif
CodeLite Plugin
Posts: 6375
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: warning non-static data member

Post 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
Make sure you have read the HOW TO POST thread
borodadada
CodeLite Enthusiast
Posts: 22
Joined: Wed Oct 16, 2013 4:20 pm
Genuine User: Yes
IDE Question: c++
Contact:

Re: warning non-static data member

Post by borodadada »

-std=gnu++11
Image
thank you Eran, work.
Image
Post Reply