+ 2
can we initailize the variables inside the class ?eg class{public: int a=10;}
6 Answers
+ 1
your answer is wrong
+ 1
error will come if we do that
+ 1
no you can't. You can use constructor to initialise you variable
+ 1
Sorry. I am wrong. I am used to other languages. As kamal said you can use a constructor to initialize variable.
0
Yes you can. You can also set the private if you need that.
0
yes we can initialize the variable inside class using const variable or class variable