PROGRAM TO ILLUSTRATE THE CONCEPT OF CLASS AND OBJECT:
// program to illustrate the concept of classes ans=d objects
#include<iostream>
using namespace std;
class student
{
private:
int rollno;
float marks;
char name[20];
public:
void getdata()
{
cout<<"ENTER NAME ";
cin>>name;
cout<<"ENTER ROLL NO";
cin>>rollno;
cout<<"ENTER MARKS";
cin>>marks;
}
void print()
{
cout<<"YOU ENTERED";
cout<<"\nNAME: "<<name;
cout<<"\nROLL NO: "<<rollno;
cout<<"\nMARKS: "<<marks;
}
};
main()
{
student s;
s.getdata();
s.print();
}
// program to illustrate the concept of classes ans=d objects
#include<iostream>
using namespace std;
class student
{
private:
int rollno;
float marks;
char name[20];
public:
void getdata()
{
cout<<"ENTER NAME ";
cin>>name;
cout<<"ENTER ROLL NO";
cin>>rollno;
cout<<"ENTER MARKS";
cin>>marks;
}
void print()
{
cout<<"YOU ENTERED";
cout<<"\nNAME: "<<name;
cout<<"\nROLL NO: "<<rollno;
cout<<"\nMARKS: "<<marks;
}
};
main()
{
student s;
s.getdata();
s.print();
}