Escolar Documentos
Profissional Documentos
Cultura Documentos
INTRODUCTION
Specifying a Class
The body of the class contains the keywords private, public, and
protected .
Private data and functions can only be accessed from within the
member functions of that class. Public data or functions, on the
other hand are accessible from outside the class.
Usually the data within a class is private and functions are public.
Creating Objects
The class declaration does not define any objects but only specifies what they
will contain.
Once a class has been declared, we can create variables (objects) of that type
by using the class name.
For eg, the class name is employee then we can create object as
employee x;
employee A,B,C;
Objects can also be created when a class is defined by placing their names
immediately after the closing brace. For example,
class employee {
}A,B,C;
Example
class Employee
{
public:
int eid,sal;
private:
void getdata( )
{
cout<<Enter ID and Salary of an employee\nl;
cin>>eid>>sal;
}
void display( )
{
cout<<Emp ID:<<eid<<\n<<Salary:<<sal;
}
};
void main( )
{
clrscr( );
Employee e;
e.getdata( );
cout<<Employee Details:;
e.display( );
getch( );
}
The symbol
1.
2.
Continued
3.
Pass-by-pointer: Like pass-by-reference method, pass-bypointer method can also be used to work directly on the actual
object used in the function call. For example, distance
adddistance(distance* d2)
Constructors
A
Automatic
The
Types Of constructor
Default
Parameterized
Copy
Constructor Overloading
We
Destructors
Thank YOU
SUBODHANA SHARMA
Neha Yadav