Suppose we have this at a header file:
class A { private: static const double x; public: A(double given_x); }; class B { private: static const double x; class A; public: B(double x_given); }; And we need to initialize the static const data member of class A during initialization.
I thought that passing the variable x_given with initializer list from the constructor of B class to A class would be ok, but I'm apparently wrong.
How can this be done?
Also, both classes might need to have the same datamember.
Edit #1: I need to declare a const variable so as to ensure that it is not changed anywhere in the class member functions. But this value is given at construction time.
staticmember isn't initialised in a constructor.