Hello I have a little problem I don't undestand what the problem is can someone explain to me?
error: ISO C++ forbids initialization of member `pi'
error: making `pi' static|
ISO C++ forbids in-class initialization of non-const static member 'pi'
The reason you're getting the error I believe is because you are initializing a variable in your class. double pi=3.14;
As far as I know, you werent able to do that before c++11. But since c++11 you can do it no problem. I just tested your program and it runs fine for me. Are you like using a really old version of c++?
Maybe someone else can come and explain. Either way, how to get around this is to just create the variable pi, then initialize it in the constructor.
Prior to C++ 11, in order to initialize a variable in your class, you needed to declare it as conststatic - denoting that it is [1] immutable (const) and [2] shared between all instantiated objects of that class (static).
Post C++ 11, the compiler should take care of that detail for you. However, if you're using an older compiler, it may complain. Specifically, with g++, you have to include the -std=c++11 flag in the compile command, eg:
g++ -std=c++11 source.cpp -o source
If you're using an up-to-date compiler like VS, it should compile without complaint.