Question: C++ Assume this class: class Space { private: int priv; public: int pub; }; //And assume this code in main() Space *sp = new Space,

C++

Assume this class:

class Space

{

private:

int priv;

public:

int pub;

};

//And assume this code in main()

Space *sp = new Space, *bar=NULL;

sp = new Space;

bar = sp;

(*bar).pub=92;

sp->pub=-82;

Which of the following best describes the code?

A.

This code will result in a memory leak.

B.

The class is invalid since there are no public class methods.

C.

The line

bar = sp;

is not allowed and will be a syntax error.

D.

The code

(*bar).pub=92;

is a runtime error since bar is NULL;

E.

The code will result in a runtime error since the pointer is never deleted.

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!