Answer to Question #315223 in C++ for Mominul

Question #315223

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-21T12:37:53-0400
class Cat
{
public:
	Cat(string color)
	{
		this->color = color;
	}
	void Purring()
	{
		cout << color << "cat is purring" << endl;
	}
	void Jumping()
	{
		cout << color << "cat is jumping" << endl;
	}
	void Sitting()
	{
		cout << color << "cat is sitting" << endl;
	}
private:
	string color;
};
int main()
{
	Cat wcat("White");
	Cat bcat("Black");
	Cat brcat("Brown");
	Cat rcat("Red");
	Cat blcat("Blue");
	Cat pcat("Purple");
	wcat.Sitting();
	bcat.Sitting();
	brcat.Jumping();
	rcat.Purring();
	blcat.Sitting();
	pcat.Jumping();


}

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