Question: What is the output when you compile and run the following code? You can assume that the codes are in main unless indicated otherwise, and
What is the output when you compile and run the following code? You can assume that the codes are in main unless indicated otherwise, and the compiler
follows c standard. All necessary directives such as iostream are included and namespace std is used.
#include iostream
using namespace std;
class Person
public:
string name;
Personstring name
name name;
void setNamestring name
name name;
string getName const
return name;
;
int main
Person new Person Tom;
const Person;
asetName Joe;
cout bgetName end ;
delete a;
Joe, because b is a new copy of the person object pointed to by a
Tom, because b is a new copy of a
Tom, because the const keyword.
Joe, because b points to the same person object as a
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
