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++11 standard. All necessary directives such as iostream are included and namespace std is used.
#include iostream
using namespace std;
class Person {
public:
string name;
Person(string _name){
name =?-name;
}
void setName(string _name){
name =_name;
}
string getName() const {
return name;
}
};
int main(){
Person*a= new Person ("Tom");
const Person*b=a;
a->setName ("Joe");
cout b->getName() end 1 ;
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.
 What is the output when you compile and run the following

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!