Is it possible to initialize a private const member variables in a constructor?
Is it possible to initialize a private const member variables in a constructor?
Use an initializer list:
Code:class Foo { public: Foo(int num):FooInt(num){} private: const int FooInt; };
"Think not but that I know these things; or think
I know them not: not therefore am I short
Of knowing what I ought."
-John Milton, Paradise Regained (1671)
"Work hard and it might happen."
-XSquared