Friday 2 May 2014

Classes & Objects
A Class is a collection of data and functions working on that data. The class follows the concept of encapsulation.
An object is an instance of class containing real world data.

In a class we simply declare member data and define member functions that work on the data but the value of the data is in correspondence to the object.

 #include<iostream.h>
#include<conio.h>
class student
{
int rno;
char name[20];
float fees;
public:
void accept()
{
cout<<"Enter the details of the student"<<endl;
cin>>rno
gets(name);
cin>>fees;
}
void disp()
{
cout<<"The rollno is '<<rno<<endl;
cout<<"The Nmae is"<<name<<endl;
cout<<"The Fees is "<<fees;
}
};
void main()
{
clrscfr();
student s;
s.accept();
s.disp();
getch();
}