Member of a class can be accessed only through the object of a class. The members are accessed as follows:
The member may be a member function or member data. The dot operator is also called the class member access operator. This is used for associating the object name with the member function.
Following are some examples to show the use of public and private accesses.
An example to show that member data can be declared in the class whereas the values
can be provided outside the class.
public: int sl, s2;
p.s1 = 5;
p.s2 = 6;
In the above example, sl and s2 have been declared to be public.