Need help with a C++ commenting question:
Indicatewhere the different constructors, assignment operator= and desctructor will run with a comment under the relevant line of code.
Start in main and use the following tags to indicate the function that will run:
Default constructorString constructorCopy constructorAssignment operatorDestructorSubstitute the variable name for the object constructed or destructed. Use a comma to separate if multiple functions are run on a line.Code to comment on:#include 2using namespace std;34class Student {5public:6friend Student OutputDuplicate (Student obj); // friend function78Student (); // Default constructor910Student (string n); // String constructor1112Student (const Student & obj); // Copy constructor1314Student& operator= (const Student & right); // Assignment operator1516~Student() ; // Destructor1718private:19string name;2021};2223// Default constructor24Student::Student() : name("no name")25{26// Intentionally left blank27}2829// String constructor30Student::Student(string n) : name(n)31{32// Intentionally left blank33}3435// Copy constructor36Student::Student(const Student & obj) : name(obj.name)37{38// Intentionally left blank39}4041// Assignment operator42Student& Student::operator= (const Student & right)43{44name=right.name;45return (*this);46}4748// Destructor49Student::~Student()50{51// Intentionally left blank52}5354//////////////////////////////////////////////////////////////////////////////55// MARK UP FROM HERE DOWN56//////////////////////////////////////////////////////////////////////////////5758// friend function59Student OutputDuplicate (Student obj)60{61Student tmp("Jack");6263cout <"creating a="" new="" student="" jame="">"creating>64Student * anotherObj = new Student ("Jane Smith");6566*anotherObj = obj;67return tmp;68}6970int main()71{72Student a, b ("John Smith");7374cout <"calling>"calling>7576a = OutputDuplicate (b);7778cout <>79}
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here