"nik" <am*******@gmai l.comschrieb im Newsbeitrag
news:11******** **************@ m79g2000cwm.goo glegroups.com.. .
hello friends,
a class having two const variables ,how can we initialize these
variables
First of all, there are no const variables. A variable is something that may
change, that is variable. A constant is something that will not change (once
it has been initialiazied). So you probably mean a constant data member.
A constant data member can only be initialized in the initializer list of a
constructor:
class SomeClass
{
const int cannotBeModifie d;
public:
SomeClass(int initilialValue) : cannotBeModifie d(initialValue)
{}
};
HTH
Heinz