Question: C++ class and pointer Quiz2 can anyone give the answer and short explanation? ============= 1. Constructors are called for which _ objects first?. A. static

C++ class and pointer Quiz2

can anyone give the answer and short explanation?

=============

1. Constructors are called for which _ objects first?.

A. static / B. Local / C. constant / D. Global

-----------------------

2. What is the name of a constructor that calls another constructor?

A. Explicit constructor / B. default constructor / C. overloaded / D. delegating constructor.

-----------------------

3. Suppose we want to model the following relationship between a Person class, Computer class, and CPU class:

C++ class and pointer Quiz2 can anyone give the answer and short

Which of the options below contains the correct class declarations?

(A)

class CPU

{

private:

string manufacturer;

}

class Computer

{

private:

string manufacturer;

CPU *cpu;

}

class Person

{

private:

string name;

Computer *computer;

}

(B)

A-)

class CPU

{

private:

string manufacturer;

}

class Computer

{

private:

string manufacturer;

CPU cpu;

}

class Person

{

private:

string name;

Computer computer;

}

-----------------------------

4. Suppose we want to be able to use the member functions set_CPU, set_RAM, and set_GPU in cascaded member function calls for a computer object. For example, we want to be able to do things like:

Computer comp;

comp.set_CPU(Intel).set_RAM(Corsair).set_GPU(Nvidia);

Which of the options below is the correct implementation of the set_CPU function?

A-)

Computer* Computer::set_cpu(string man)

{

manufacturer = man;

return this;

}

B-)

Computer* Computer::set_cpu(string man)

{

manufacturer = man;

return *this;

}

C-)

Computer& Computer::set_cpu(string man)

{

manufacturer = man;

return this;

}

D-)

Computer& Computer::set_cpu(string man)

{

manufacturer = man;

return *this;

}

-------------------------------

5. (( True or False))

-A) The destructor for an object is invoked when the main function goes out of scope.

-B) While the destructor is running the memory held by the object is released.

Person Has A Computer Has A CPU

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!