Classes have two types of members: data members and member functions.
Data members.
There are two types of data: public data and private data.
Public Data Members: data members that can be changed
from
anywhere,
by anything Private Data Members: data members that can be changed
only
by the member functions inside the class
How to declare member functions.
Function members can only be declared within the class declaration
Function members can be defined anywhere, within or ouside the
class declaration
Note: To define functions outside the class declaration
you need to use a scope operator (two colons).
This is used to tell the compiler to which class the function belongs.
example: void
beginning_class::show_value(void)
name of class scope operator
function name
Public Member Functions: member functions that can be called
on by any other function, including both outside and inside the class
Private Member Functions: member functions that can only
be called by other functions that are members of the same class
What is a constructor?
It is a special function.
It is called when a new object of the class is declared.
It provides a chance to initialize objects.
It always has the same name as the class in which it is defined.
It has no return type, even you can not write it as void.
Class and Object: A variable of the class type is called an
object.
For example, int
Number_Of_Students; //
int is a class and Number_Of_Students is an object.
Circle
swimming_pool;
// Circle is a class and swimming_pool is an object.
Boy
Austin, Roger;
// Boy is a class and Austin and Roger are objects.
Note on the above example: // measurement functions
float Circumference() const;
float Area() const;
Constant member function can not modify
the object's member data.