



























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An in-depth explanation of static data members in object- oriented programming (oop). Static data members are variables that belong to a class rather than an object, and they are shared among all instances of the class. The definition, syntax, initialization, accessing, and uses of static data members, as well as the differences between static data members and instance variables.
Typology: Slides
1 / 35
This page cannot be seen from the preview
Don't miss anything!




























Defining Static Data Member
Defining Static Data Member
class ClassName{… static DataType VariableName;}; DataType ClassName::VariableName;
class
Student{ private: static
int
noOfStudents;
public:… }; int Student::noOfStudents
/*private
static
member
cannot
be accessed
outside
the
class
except
for
initialization*/
class Student{public: static int noOfStudents; };int Student::noOfStudents;int main(){ Student aStudent;aStudent.noOfStudents = 1;Student::noOfStudents = 1; }
class Student{public: static int noOfStudents; };int Student::noOfStudents;int main(){ { Student aStudent;aStudent.noOfStudents = 1;} Student::noOfStudents = 1; }
class
Student{ … public:static
int
noOfStudents;
Student();~Student();… };int^ Student::noOfStudents