Class: Class is a collection of object, Class is called using the keyword class.
General form:Class class-name
Private data and functions
Public data and functions
}object name list;
a class contain private as well as public parts. Default defined parts in a class
are private, private parts are cannot access by any function because that is not a member of a class. In the above program “int roll.no, char name, int age”
To make parts of a class as public, you can define parts, after the public keyword, all variable and functions accessed the parts which are defined after the public keyword. In above program “void read(), void calc(), void display(int i)”
Once you defined a class you can create an object of that class by using the class name.
EX: stack mystack
Object: Object is an instance of a class
When you declare an object of a class, you can create an instance of a class, In this case, my stack
is an instance of a stack
The:: is a scope resolution operator.
that says the compiler read()
belongs to the student class.
“ Void student::read() ”
Using namespace std;
Void student :: read()
Cout<<”enter reg non”;
Cout<<”enter student namen”;
Cout<<”enter age of the studentn”
Cout<<”student roll no isn”<<roll.no;
Cout<<”name of the student isn”<<name;
Cout<<”age of the student isn”<<age;