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

Oracle Autonomous Database In Enterprise Architecture

Authors: Bal Mukund Sharma, Krishnakumar KM, Rashmi Panda

1st Edition

1801072248, 978-1801072243

More Books

Students also viewed these Databases questions

Question

Find each root. 0.001

Answered: 1 week ago

Question

Technology. Refer to Case

Answered: 1 week ago