fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. using namespace std;
  5.  
  6. class Tutor {
  7. public:
  8. Tutor(string, int);
  9. void Print() const;
  10.  
  11. private:
  12. string name;
  13. vector<string> students;
  14. };
  15.  
  16. Tutor::Tutor(string tutorName, int numStudents) : name(tutorName), students(numStudents) {}
  17.  
  18. void Tutor::Print() const {
  19. if (students.size() == 0){
  20. cout << name << " is solo" << endl;
  21. }
  22. else {
  23. cout << name << " teaches " << students.size() << " students" << endl;
  24. }
  25. }
  26.  
  27. int main() {
  28. Tutor myTutor("Gil", 0);
  29. Tutor yourTutor("Jan", 6);
  30.  
  31. yourTutor.Print();
  32. myTutor.Print();
  33.  
  34. return 0;
  35. }
Success #stdin #stdout 0s 5300KB
stdin
Standard input is empty
stdout
Jan teaches 6 students
Gil is solo