Advertisement
NOZXII

Classes

Nov 21st, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. class Animal
  5. {
  6. private:
  7. std::string Color;
  8. std::string Size;
  9. public:
  10. void setColor(std::string a)
  11. {
  12. Color = a;
  13. };
  14. void setSize(std::string b)
  15. {
  16. Size = b;
  17. }
  18. std::string getColor()
  19. {
  20. return Color;
  21. }
  22. std::string getSize()
  23. {
  24. return Size;
  25. }
  26. };
  27.  
  28. int main()
  29. {
  30. Animal dogColor;
  31. Animal dogSize;
  32. dogColor.setColor("Brown");
  33. dogSize.setSize("Large");
  34.  
  35. std::cout << "You have a " << dogSize.getSize() << ", "<< dogColor.getColor() << " dog!";
  36.  
  37. return 0;
  38. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement