Class:
Class is a user define data type.
for e.g
Class is a user define data type.
A class must be declare by a keyword 'class'.
Basically a class contain member function and member variable.
A class may be empty.
In C++ class end with a semicolon..
for e.g
class sap
{
int i , j; //member variable and also global variable
public:
void add() // member function
{
i=12;
j=34;
cout<<"The sum is="<<(i+j);
}
} ; // end class sap
void main()
{
sap s;
s.add();
}
OUTPUT:
The sum is=46
No comments:
Post a Comment