Question: C++ class and pointer Quiz can anyone give the answer and short explanation? ============= 1. Which of the options below is equivalent to this->y? A.

C++ class and pointer Quiz

can anyone give the answer and short explanation?

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

1. Which of the options below is equivalent to this->y?

A. &(this.y) / B. *(this.y) / C. (&this).y / D. (*this).y

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

2. Suppose a program has a Printer class:

class Printer

{

private:

int amount_of_ink;

};

Which of the options below is considered a dangerous reference return?

(A) Printer* set_amount_of_ink(int);

(B) Printer& set_amount_of_ink(int);

(C) int& set_amount_of_ink(int);

(D) int* set_amount_of_ink(int);

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

3.

class Car

{

Public:

Car(const string &ma, const string &mo, int ye)

{ make = ma; model = mo; year = ye;

cout<

}

~Car() { cout<

private:

string make;

string model;

int year;

};

class Person

{

Person(const string &n, int a, const Car&c)

{ name = n; age = ag; car= c;

cout<

}

~Person() { cout<

string name;

int age;

Car car;

};

int main()

{

Car c(Toyota, Corolla, 2017);

Person p(James Bond, 45, c);

}

What is the output of this program?

(A)

CAR CON

CAR CON

PERSON CON

PERSON DES

CAR DES

(B)

CAR CON

PERSON CON

PERSON DES

CAR DES

(C)

CAR CON

CAR CON

PERSON CON

PERSON DES

CAR DES

CAR DES

(D)

CAR CON

PERSON CON

PERSON DES

CAR DES

CAR DES

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

4. Which access specifier applies to friend functions?

(A) public (B) private (C) protected (D) none of them

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

5. << True and False>>

A) A destructor receives no parameters.

B) A destructor does not return a value.

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!