Question: ************* Code *************************** #include #include #include #include #include #include using namespace std::literals; using namespace std; class animal { public: virtual ~animal() { } virtual std::string

************* Code ***************************
#include #include #include #include #include #include
using namespace std::literals; using namespace std;
class animal { public: virtual ~animal() { } virtual std::string kind() const = 0; };
using animal_ptr = std::unique_ptr;
template animal_ptr make_animal(T&& t) { using type = std::remove_cvref_t; return animal_ptr{ new type(std::forward(t)) }; }
class cat : virtual public animal { virtual ~cat() {} std::string kind() const override { return "Felis catus"s; } };
class dog : virtual public animal { private: string something;
public: dog() = delete; dog(dog& obj) = default; dog& operator = (const dog&) = default; // Constructor dog(string const& str) : something(str) {
}
string kind() const override { return "Canis lupus familiaris"s; }
string const& name() { return something; } };
// Write dogcat class here
Just follow the steps.. Don't worry about the main method
Writing the dogcat Class Unfortunately you have to deal with hybrid organisms too --so you need to define a class called dogcat as follows: the class (multiply) inherits both publicly and virtually from both dog and from cat, the class has a default constructor that invokes the parent dog constructor with the name "hybrid" and the default cat constructor, the class has a constructor that has two parameters (dog const& d and cat const& c) and invokes the corresponding parameter class' copy constructor passing in d orc respectively, the class has a defaulted copy constructor, the class has a defaulted copy assignment operator, and, the class has a kind() member function that overrides animal::kind and returns the result of calling dog's kind(), + (i.e., string append), the string " +", + (i.e., string append), and calling cat's kind(). Tips: A dogcat's kind() function returns a string that is a concatenation of its dog's kind()," + ", and its cat's kind(). A dogcat's name is always "hybrid" if default constructed. Writing the dogcat Class Unfortunately you have to deal with hybrid organisms too --so you need to define a class called dogcat as follows: the class (multiply) inherits both publicly and virtually from both dog and from cat, the class has a default constructor that invokes the parent dog constructor with the name "hybrid" and the default cat constructor, the class has a constructor that has two parameters (dog const& d and cat const& c) and invokes the corresponding parameter class' copy constructor passing in d orc respectively, the class has a defaulted copy constructor, the class has a defaulted copy assignment operator, and, the class has a kind() member function that overrides animal::kind and returns the result of calling dog's kind(), + (i.e., string append), the string " +", + (i.e., string append), and calling cat's kind(). Tips: A dogcat's kind() function returns a string that is a concatenation of its dog's kind()," + ", and its cat's kind(). A dogcat's name is always "hybrid" if default constructed
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
