fork download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. class Tutor {
  6. public:
  7. Tutor();
  8. Tutor(string tutorName);
  9. void Print() const;
  10.  
  11. private:
  12. string name;
  13. string topic;
  14. };
  15.  
  16. Tutor::Tutor() : name("NoName"), topic("NoTopic") {}
  17.  
  18. Tutor::Tutor(string tutorName) : name(tutorName), topic("NoTopic") {}
  19.  
  20. void Tutor::Print() const {
  21. cout << name << " tutors " << topic << endl;
  22. }
  23.  
  24. int main() {
  25. Tutor myTutor;
  26. Tutor yourTutor("Kai");
  27.  
  28. yourTutor.Print();
  29. myTutor.Print();
  30.  
  31. return 0;
  32. }
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
Kai tutors NoTopic
NoName tutors NoTopic