Complete the Cat class so the main function above produces the following output:
White cat is sitting Black cat is sitting
Brown cat is jumping
Red cat is purring Blue cat is sitting Purple cat is jumping
#include<iostream>
#include<string>
using namespace std;
class Cat{
string color;
public:
Cat(string _color):color(_color){}
void Sit(){
cout<<color<<" cat is sitting ";
};
void Jump() {
cout<<color<<" cat is jumping ";
};
void Pure() {
cout<<color<<" cat is purring ";
};
};
int main(int argc, char *argv[]){
Cat w("White");
Cat b("Black");
Cat br("Brown");
w.Sit();
b.Sit();
br.Jump();
cout<<endl;
Cat r("Red");
Cat bl("Blue");
Cat p("Purple");
r.Pure();
bl.Sit();
p.Jump();
}
Comments
Leave a comment