Need help with a C++ commenting question: Indicate where the different constructors, assignment operator= and desctructor will run with a comment under the relevant line of code. Start in main and use...


Need help with a C++ commenting question:



Indicate
where 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 constructor

String constructor

Copy constructor

Assignment operator
Destructor



Substitute 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;
3
4class Student {
5public:
6friend Student OutputDuplicate (Student obj); // friend function
7
8Student (); // Default constructor
9
10Student (string n); // String constructor
11
12Student (const Student & obj); // Copy constructor
13
14Student& operator= (const Student & right); // Assignment operator
15
16~Student() ; // Destructor
17
18private:
19string name;
20
21};
22
23// Default constructor
24Student::Student() : name("no name")
25{
26// Intentionally left blank
27}
28
29// String constructor
30Student::Student(string n) : name(n)
31{
32// Intentionally left blank
33}
34
35// Copy constructor
36Student::Student(const Student & obj) : name(obj.name)
37{
38// Intentionally left blank
39}
40
41// Assignment operator
42Student& Student::operator= (const Student & right)
43{
44name=right.name;
45return (*this);
46}
47
48// Destructor
49Student::~Student()
50{
51// Intentionally left blank
52}
53
54//////////////////////////////////////////////////////////////////////////////
55// MARK UP FROM HERE DOWN
56//////////////////////////////////////////////////////////////////////////////
57
58// friend function
59Student OutputDuplicate (Student obj)
60{
61Student tmp("Jack");
62
63cout <"creating a="" new="" student="" jame="">
64Student * anotherObj = new Student ("Jane Smith");
65
66*anotherObj = obj;
67return tmp;
68}
69
70int main()
71{
72Student a, b ("John Smith");
73
74cout <"calling>
75
76a = OutputDuplicate (b);
77
78cout <>
79}












Jun 07, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here