Advertisement
Guest User

Untitled

a guest
Dec 9th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. #include <iostream>
  2. #include<string>
  3. using namespace std;
  4. class student
  5. {public:
  6. int id,age;
  7. void setname(string na)
  8. {name=na;}
  9. void setscore(float sc)
  10. {score=sc;}
  11. string getname(){return name;}
  12. float getscore(){return score;}
  13. student(int i,int a, string n,float s)
  14. {id=i;age=a;name=n;score=s;}
  15. student ();
  16. ~student(){cout<<"object destroyed\n";}
  17. private:
  18. string name;
  19. float score;
  20. };
  21. int main()
  22. {student s1(1,19,"Lojain",100),s2;
  23. string namo;float sco;
  24. cout <<"Enter ID";cin>>s2.id;
  25. cout <<"Enter age";cin>>s2.age;
  26. cout<<"Enter Name";cin>>namo;
  27. cout<<"Enter sco";cin>>sco;
  28. s2.setname(namo);s2.setscore(sco);
  29. cout<<"first student data:\nID:"<<s1.id<<"\nage:"<<s1.age<<"\nName:"<<s1.getname()<<"\nscore:"<<s1.getscore();
  30. cout<<"second student data:\nID:"<<s2.id<<"\nage:"<<s2.age<<"\nName:"<<s2.getname()<<"\nscore:"<<s2.getscore();
  31. return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement