C++ Institute CPA - C++ Certified Associate Programmer CPA-21-02 Question # 14 Topic 2 Discussion

C++ Institute CPA - C++ Certified Associate Programmer CPA-21-02 Question # 14 Topic 2 Discussion

CPA-21-02 Exam Topic 2 Question 14 Discussion:
Question #: 14
Topic #: 2

What happens when you attempt to compile and run the following code?

#include

#include

using namespace std;

struct Person {

string name;

int age;

};

class First

{

Person *person;

public:

First() {person = new Person;

person?>name = "John";

person?>age = 30;

}

void Print(){

cout<name << " "<< person?>age;

}

};

int main()

{

First t[2];

for (int i=0; i<2; i++)

t[i].Print();

}


A.

It prints: 30


B.

It prints: John


C.

It prints: John 31


D.

It prints: John 30John 30


Get Premium CPA-21-02 Questions

Contribute your Thoughts:


Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.