C++ Institute CPA - C++ Certified Associate Programmer CPA-21-02 Question # 61 Topic 7 Discussion

C++ Institute CPA - C++ Certified Associate Programmer CPA-21-02 Question # 61 Topic 7 Discussion

CPA-21-02 Exam Topic 7 Question 61 Discussion:
Question #: 61
Topic #: 7

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

#include

using namespace std;

class BaseClass

{

public:

int *ptr;

BaseClass(int i) { ptr = new int(i); }

~BaseClass() { delete ptr; delete ptr;}

void Print() { cout << *ptr; }

};

void fun(BaseClass x);

int main()

{

BaseClass o(10);

fun(o);

o.Print();

}

void fun(BaseClass x) {

cout << "Hello:";

}


A.

It prints: Hello:1


B.

It prints: Hello:


C.

It prints: 10


D.

Runtime error.


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.