Say, I have a class .h file named Ninja
I have two member functions and the default name is set to Ninja master and discple_ child is set to nullptr
Below is a snippit of the public/private of my class:
private:
std::string name_;
std::shared_ptr<Ninja> disciples_;
public:
Ninja(std::string name = "Ninja Master")
: name_{name},
disciples_{std::shared_ptr<Ninja>(nullptr)}
{}
~Ninja() = default;
Ninja(const Ninja& copy2); //trying to make a copy constructor here
Ninja& operator=(const Ninja&); // I also need help creating an assignment operator too
I want to make a deep copy constructor but I am getting errors.
Below is the snippet for my deep copy constructor in the .cpp file.
Ninja::Ninja(const Ninja& copy2) {
Ninja a();
a = copy2; //error cannot convert const Ninja to Ninja() in assignment
}