fork download
  1. #include <string>
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6.  
  7. class Cat{
  8. private :
  9. string m_name;
  10. string m_owner;
  11. int m_price;
  12. string m_color;
  13. double m_weight;
  14. void sellCat(string whoBought,int price);
  15. public :
  16. Cat(); //this is the default constructor notice no arguments
  17. Cat(const string name , const string color, int price, double weight, const string owner);
  18. void changeColor(string newColor);
  19. void setName(string name);
  20. void showCat();
  21. };
  22.  
  23.  
  24. Cat::Cat(const string name , const string color, int price = 0 , double weight = 0, const string owner = "NotSoldYet"){
  25. m_name = name;
  26. m_owner = owner;
  27. m_color = color;
  28. m_price = price ;
  29. m_weight = weight;
  30. }
  31.  
  32. void Cat::showCat()
  33. {
  34. cout << "Name is " << m_name << endl << "Owner is " << m_owner;
  35.  
  36. }
  37.  
  38.  
  39.  
  40. int main()
  41. {
  42. Cat newCat("Garfield","Green");
  43. newCat.showCat();
  44.  
  45. }
Success #stdin #stdout 0.02s 2860KB
stdin
Standard input is empty
stdout
Name is Garfield
Owner is NotSoldYet