fork download
  1. #include <iostream>
  2. using namespace std;
  3. class Person{
  4. protected:
  5. string name;
  6. public:
  7. Person(string name):name(name){
  8. }
  9. void setName(string name){
  10. this->name=name;
  11. }
  12. string getName(){
  13. return name;
  14. }
  15. };
  16. class Student: public Person{
  17. public:
  18. Student(string name):Person(name){}
  19. string getLast(){
  20. return name;
  21. }
  22. };
  23. int main() {
  24. Person person("Oleg");
  25. Student student("Kristina");
  26. cout<<person.getName()<<endl;
  27. cout<<student.getName();
  28. student.setName("Petro");
  29. cout<<student.getName();
  30. // your code goes here
  31. return 0;
  32. }
Success #stdin #stdout 0s 5316KB
stdin
Standard input is empty
stdout
Oleg
KristinaPetro