Answer to Question #315035 in C++ for Mominul

Question #315035

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

1
Expert's answer
2022-03-21T06:50:04-0400
#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();
	
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog