1
0

usett1.cpp 953 B

12345678910111213141516171819202122232425262728293031
  1. // usett1.cpp -- using base class and derived class
  2. #include <iostream>
  3. #include "tabtenn1.h"
  4. int main ( void )
  5. {
  6. using std::cout;
  7. using std::endl;
  8. TableTennisPlayer player1("Tara", "Boomdea", false);
  9. RatedPlayer rplayer1(1140, "Mallory", "Duck", true);
  10. rplayer1.Name(); // derived object uses base method
  11. if (rplayer1.HasTable())
  12. cout << ": has a table.\n";
  13. else
  14. cout << ": hasn't a table.\n";
  15. player1.Name(); // base object uses base method
  16. if (player1.HasTable())
  17. cout << ": has a table";
  18. else
  19. cout << ": hasn't a table.\n";
  20. cout << "Name: ";
  21. rplayer1.Name();
  22. cout << "; Rating: " << rplayer1.Rating() << endl;
  23. // initialize RatedPlayer using TableTennisPlayer object
  24. RatedPlayer rplayer2(1212, player1);
  25. cout << "Name: ";
  26. rplayer2.Name();
  27. cout << "; Rating: " << rplayer2.Rating() << endl;
  28. // std::cin.get();
  29. return 0;
  30. }