Tuesday, September 7, 2010

Classes in Cplusplus | How to use Class in C++

,
A class is a group of Objects that have the identical properties,common behavior, and shared relationship.
The entire group of data and code of an object can be built as a user-defined data type using class.
Objects are nothing but variable of type class.
A class is a model and not a true structure of the object
.However it shares the property names or operations with other objects of the class.


#include<iostream.h>
#include<conio.h>
 Class p
{
Private :
Char n [20];
Public :
Float h ;
Float w ;
} ;
Int main ()
{
Clrscr ()
p a;
//a.n =”Sanjay”;// not accessible
a.h = 5.5;
a.w = 38;
cout <<”H : “<
cout<<”W: “<
return 0;
}

OUTPUT

Height : 5.5
Weight : 38

0 comments to “Classes in Cplusplus | How to use Class in C++”

Post a Comment