Indicate where the different constructors, assignment operator- and desctructor will run with a comment under the relevant line of code. HINT: run the program but make modifications that help see what is going on or step through using https://onlinegdb.com. Start in main and use the following tags to indicate the function that will run:

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Need help with C++ Question.

 

The question is attatched as a image, and the code is copied below:

 

#include <iostream>  
2 using namespace std;  
3    
4 class Student {  
5 public:  
6 friend Student OutputDuplicate (Student obj); // friend function  
7    
8 Student (); // Default constructor  
9    
10 Student (string n); // String constructor  
11    
12 Student (const Student & obj); // Copy constructor  
13    
14 Student& operator= (const Student & right); // Assignment operator  
15    
16 ~Student() ; // Destructor  
17    
18 private:  
19 string name;  
20    
21 };  
22    
23 // Default constructor  
24 Student::Student() : name("no name")  
25 {  
26 // Intentionally left blank  
27 }  
28    
29 // String constructor  
30 Student::Student(string n) : name(n)  
31 {  
32 // Intentionally left blank  
33 }  
34    
35 // Copy constructor  
36 Student::Student(const Student & obj) : name(obj.name)  
37 {  
38 // Intentionally left blank  
39 }  
40    
41 // Assignment operator  
42 Student& Student::operator= (const Student & right)  
43 {  
44 name=right.name;  
45 return (*this);  
46 }  
47    
48 // Destructor  
49 Student::~Student()  
50 {  
51 // Intentionally left blank  
52 }  
53    
54 //////////////////////////////////////////////////////////////////////////////  
55 // MARK UP FROM HERE DOWN  
56 //////////////////////////////////////////////////////////////////////////////  
57    
58 // friend function  
59 Student OutputDuplicate (Student obj)  
60 {  
61 Student tmp("Jack");  
62    
63 cout <<"Creating a new student Jame smith\n";  
64 Student * anotherObj = new Student ("Jane Smith");  
65    
66 *anotherObj = obj;  
67 return tmp;  
68 }  
69    
70 int main()  
71 {  
72 Student a, b ("John Smith");  
73    
74 cout <<"calling OutputDuplicate\n\n";  
75    
76 a = OutputDuplicate (b);  
77    
78 cout <<"\nExiting\n";  
79 }
Indicate where the different constructors, assignment operator- and desctructor will run with a comment under the relevant line of code. HINT: run the program but make modifications that help see what is going on or step through using https://onlinegdb.com.
Start in main and use the following tags to indicate the function that will run:
Default constructor <object name>
String constructor <object name>
Copy constructor <object name
Assignment operator
Destructor <object name>
Substitute the variable name for the object constructed or destructed. Use a comma to separate if multiple functions are run on a line.
Transcribed Image Text:Indicate where the different constructors, assignment operator- and desctructor will run with a comment under the relevant line of code. HINT: run the program but make modifications that help see what is going on or step through using https://onlinegdb.com. Start in main and use the following tags to indicate the function that will run: Default constructor <object name> String constructor <object name> Copy constructor <object name Assignment operator Destructor <object name> Substitute the variable name for the object constructed or destructed. Use a comma to separate if multiple functions are run on a line.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
ADT and Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education