Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<string>
- using namespace std;
- class student
- {public:
- int id,age;
- void setname(string na)
- {name=na;}
- void setscore(float sc)
- {score=sc;}
- string getname(){return name;}
- float getscore(){return score;}
- student(int i,int a, string n,float s)
- {id=i;age=a;name=n;score=s;}
- student ();
- ~student(){cout<<"object destroyed\n";}
- private:
- string name;
- float score;
- };
- int main()
- {student s1(1,19,"Lojain",100),s2;
- string namo;float sco;
- cout <<"Enter ID";cin>>s2.id;
- cout <<"Enter age";cin>>s2.age;
- cout<<"Enter Name";cin>>namo;
- cout<<"Enter sco";cin>>sco;
- s2.setname(namo);s2.setscore(sco);
- cout<<"first student data:\nID:"<<s1.id<<"\nage:"<<s1.age<<"\nName:"<<s1.getname()<<"\nscore:"<<s1.getscore();
- cout<<"second student data:\nID:"<<s2.id<<"\nage:"<<s2.age<<"\nName:"<<s2.getname()<<"\nscore:"<<s2.getscore();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement