Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Databases

Authors: Ian Robinson, Jim Webber, Emil Eifrem

1st Edition

1449356265, 978-1449356262

Students also viewed these Databases questions

Question

What do you understand by securities lending?

Answered: 1 week ago

Question

6. Does your speech have a clear and logical structure?

Answered: 1 week ago