While initializing a static data member we write:-
int Student::noOfStudents;
Here we are specifying the return type as 'int'; but this is not a function; why there is need to specify return type; similarly we have not defined the return type in prototype or once we declared static data member inside the body of the class; kindly clarify?
int Student::noOfStudents;
Here we are specifying the return type as 'int'; but this is not a function; why there is need to specify return type; similarly we have not defined the return type in prototype or once we declared static data member inside the body of the class; kindly clarify?
class Student{
private:
static int noOfStudents;
public:
…
};
int Student::noOfStudents = 0;
or
int Student::noOfStudents;
Both initializations result in same value that is 0. Return type is important as without that coder won't know what to store.
private:
static int noOfStudents;
public:
…
};
int Student::noOfStudents = 0;
or
int Student::noOfStudents;
Both initializations result in same value that is 0. Return type is important as without that coder won't know what to store.
0 Comments
Please add nice comments or answer ....