Part B: 12 questions worth 2marks each. (Total 24 Marks)
#include<iostream>
#include<string>
using namespace std;
class Mouse
{
private:
string name;
int age;
public:
Mouse() = default;
~Mouse();
Mouse(string name, int age);
Mouse(const Mouse&); //copy constructor
TODO...; //move constructor
};
Mouse::~Mouse()
{
cout << "Destructor" << endl;
}
Mouse::Mouse(string _name, int _age)
{
name = _name;
age = _age;
cout<<"Mouse constructing"<<endl;
}
Mouse::Mouse(const Mouse& copyMouse)
{
name = copyMouse.name;
age = copyMouse.age;
cout<<"Copy Mouse constructor"<<endl;
}
Mouse::Mouse(Mouse && mMouse){
TODO....
cout<<"Move Mouse constructor"<<endl;
}
int main()
{
Mouse myMouse("Katty", 2);
Mouse secondMouse=myMouse;
TODO........;// call move constructor
return 0;
}