1. Homepage
  2. Exam
  3. [2021] UOW - CSCI251 Advanced Programming - C++ - Final Exam - Part B - Q3 Move Constructor

[2021] UOW - CSCI251 Advanced Programming - C++ - Final Exam - Part B - Q3 Move Constructor

This question has been solved
Engage in a Conversation

Part B: 12 questions worth 2marks each. (Total 24 Marks)


CourseNana.COM


CourseNana.COM

 3) You will write 3 small blocks of code in the sections (T_O_D_O_…) to demonstrate move constructor. You do not need to write the whole program. The code and the running result below are the suggestions for your code. CourseNana.COM

  CourseNana.COM

#include<iostream> CourseNana.COM

#include<string> CourseNana.COM

using namespace std; CourseNana.COM

  CourseNana.COM

class Mouse CourseNana.COM

{                                                                                                           CourseNana.COM

private: CourseNana.COM

string name; CourseNana.COM

int age; CourseNana.COM

public: CourseNana.COM

Mouse() = default; CourseNana.COM

~Mouse(); CourseNana.COM

Mouse(string name, int age); CourseNana.COM

Mouse(const Mouse&); //copy constructor CourseNana.COM

  CourseNana.COM

TODO...; //move constructor CourseNana.COM

}; CourseNana.COM

  CourseNana.COM

Mouse::~Mouse() CourseNana.COM

{ CourseNana.COM

cout << "Destructor" << endl; CourseNana.COM

} CourseNana.COM

Mouse::Mouse(string _name, int _age) CourseNana.COM

{ CourseNana.COM

name = _name; CourseNana.COM

age = _age; CourseNana.COM

cout<<"Mouse constructing"<<endl; CourseNana.COM

} CourseNana.COM

Mouse::Mouse(const Mouse& copyMouse) CourseNana.COM

{ CourseNana.COM

name = copyMouse.name; CourseNana.COM

age = copyMouse.age; CourseNana.COM

cout<<"Copy Mouse constructor"<<endl; CourseNana.COM

} CourseNana.COM

Mouse::Mouse(Mouse && mMouse){ CourseNana.COM

TODO.... CourseNana.COM

cout<<"Move Mouse constructor"<<endl; CourseNana.COM

} CourseNana.COM

int main() CourseNana.COM

{ CourseNana.COM

Mouse myMouse("Katty", 2); CourseNana.COM

Mouse secondMouse=myMouse; CourseNana.COM

TODO........;// call move constructor CourseNana.COM

return 0; CourseNana.COM

} CourseNana.COM

Get the Solution to This Question

WeChat (微信) WeChat (微信)
Whatsapp WhatsApp
C++代写,STL代写,Overload代写,Constant Pointer代写,Lifetime of Object代写,Static and Dynamic Library代写,Move Constructor代写,C++代编,STL代编,Overload代编,Constant Pointer代编,Lifetime of Object代编,Static and Dynamic Library代编,Move Constructor代编,C++代考,STL代考,Overload代考,Constant Pointer代考,Lifetime of Object代考,Static and Dynamic Library代考,Move Constructor代考,C++help,STLhelp,Overloadhelp,Constant Pointerhelp,Lifetime of Objecthelp,Static and Dynamic Libraryhelp,Move Constructorhelp,C++作业代写,STL作业代写,Overload作业代写,Constant Pointer作业代写,Lifetime of Object作业代写,Static and Dynamic Library作业代写,Move Constructor作业代写,C++编程代写,STL编程代写,Overload编程代写,Constant Pointer编程代写,Lifetime of Object编程代写,Static and Dynamic Library编程代写,Move Constructor编程代写,C++programming help,STLprogramming help,Overloadprogramming help,Constant Pointerprogramming help,Lifetime of Objectprogramming help,Static and Dynamic Libraryprogramming help,Move Constructorprogramming help,C++assignment help,STLassignment help,Overloadassignment help,Constant Pointerassignment help,Lifetime of Objectassignment help,Static and Dynamic Libraryassignment help,Move Constructorassignment help,C++solution,STLsolution,Overloadsolution,Constant Pointersolution,Lifetime of Objectsolution,Static and Dynamic Librarysolution,Move Constructorsolution,