# include<iostream.h>
class Student
{
private:
int rollNo;
int semNo;
public:
Student()
{
rollNo=0;
semNo=0;
}
Student(int r,int s)
{
rollNo=r;
semNo=s;
}
void setRollNo(int r)
{
if(r>0)
{
rollNo=r;
}
else
{
cout<<"Sorry, not properly initialized";
}
}
int getRollNo()
{
return rollNo;
}
void setSemNo(int s)
{
semNo=s;
}
int getSemNo()
{
return semNo;
}
void input()
{
cout<<"Enter the value of RollNo: ";
int r;
cin>>r;
setRollNo(r);
cout<<"Enter the value of SemesterNo: ";
int s;
cin>>s;
setSemNo(s);
}
void display()
{
cout<<"the value of RollNo: ";
cout<<getRollNo();
cout<<endl;
cout<<"the value of SemesterNo: ";
cout<<getSemNo();
cout<<endl;
}
};
void main()
{
Student amir;
Student ali;
amir.input();
amir.display();
cout<<endl;
cout<<"***********"<<endl;
ali.input();
ali.display();
}
class Student
{
private:
int rollNo;
int semNo;
public:
Student()
{
rollNo=0;
semNo=0;
}
Student(int r,int s)
{
rollNo=r;
semNo=s;
}
void setRollNo(int r)
{
if(r>0)
{
rollNo=r;
}
else
{
cout<<"Sorry, not properly initialized";
}
}
int getRollNo()
{
return rollNo;
}
void setSemNo(int s)
{
semNo=s;
}
int getSemNo()
{
return semNo;
}
void input()
{
cout<<"Enter the value of RollNo: ";
int r;
cin>>r;
setRollNo(r);
cout<<"Enter the value of SemesterNo: ";
int s;
cin>>s;
setSemNo(s);
}
void display()
{
cout<<"the value of RollNo: ";
cout<<getRollNo();
cout<<endl;
cout<<"the value of SemesterNo: ";
cout<<getSemNo();
cout<<endl;
}
};
void main()
{
Student amir;
Student ali;
amir.input();
amir.display();
cout<<endl;
cout<<"***********"<<endl;
ali.input();
ali.display();
}
No comments:
Post a Comment