Person(); You can add something in other file
Person();
Person(){}; "empty"
Person(){};
With some defined atributes
Person(): name("Unnamed"), age(0) {};
Person(const std::string& name, unsigned age): name(name), age(age) {};
class Animal{ private: string name; public: Animal() { cout << "Animal created. Constructor." << endl; } Animal(const Animal& other) :name(other.name) { cout << "Animal created by coping. Copy constr." << endl; } //Can use: other.speak(); only if speak is const void setName(string nameSet) {this->name=nameSet;}; void speak() const { cout << "My name is: " << name << endl; } //const prevent name="Julian"; ~Animal(){ cout<<"Destructor"<<endl;} //Destructor } int main(){ Animal dog; dog.setName("Bobby"); dog.speak(); Animal cat = dog; //COPY cat.speak(); Animal mouse(cat); //COPY }
Person (Person&& other): name(std::move(other.name), age(std::move(other.age){};
USE: Animal secondDog = move(firstDog);
Animal secondDog = move(firstDog);
There was an error while loading. Please reload this page.