Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ questions classes inh poly etc do all 1. How may a constructor b ovrloadd? C

ID: 3887754 • Letter: C

Question

C++ questions classes inh poly etc do all

1. How may a constructor b ovrloadd? Choos all that apply

a. Typ of paramtrs

b. Ordr of paramtr typs

c. Rturn typ

d. By nam     

2. Considr th statmnt blow. Which of th Big-Fiv functions will b usd in this cas?

            Car mustangCar = gtCarFromFactory(“Mustang”); // gtCarFromFactory rturns a Car objct

3. xplain your rational for choosing th answr you did for #2 abov

4. Is it possibl to hav mor than on dstructor in a class? Why or why not?

5. If a class objct is dynamically allocatd in mmory, dos its constructor xcut? If so, whn?

6. Mmbrs of a class objct may b accssd through a pointr to th objct by using th _________ oprator.

7. Giv th statmnt to call function lookUpInfo and pass it a vry larg objct of typ objHumongous. Th function mrly looks at th information and rturns a string valu. B fficint, and guard against any changs to th data you pass to th function.

8. Whn a mmbr function’s body is writtn insid a class dclaration, th function is ________________.

9. Find all rrors in th following class:

class Circl: {

privat

doubl cntrX;

doubl cntrY;

doubl radius;

public stCntr(doubl, doubl);

stRadius(doubl);

}

10. (7 pts) How can th compilr dtrmin if a constructor is a copy constructor?

11. (3 pts) What is th this pointr?

12. (3pts) A(n) __________ is a spcial constructor, calld whn a nw objct is initializd with anothr objct’s data.

13. (9 pts) List th thr cass whr a copy constructor is invokd implicitly.

14. Considr th following dfinition for class Assmbly :

                        class Assmbly {

public:

int valu;

};

            and th variabl ptr_a is dclard and initializd as such:

           

                        Assmbly *ptr_a = nw Assmbly;

Us th dot oprator ( . ) to assign 5 to th valu fild of th objct to which ptr_a points.

Us th arrow oprator ( -> ) to assign 23 to th valu fild of th objct to which ptr_a points.

15. Tru or fals: Th compilr will gnrat a dfault dstructor if on if not dfind xplicitly.

16. Assum you hav an lvalu namd nwItm, which is a vry larg objct. Giv th statmnt to assign nwItm to xisting objct of th sam typ calld oldItm, via a mov assignmnt.

17. Giv th rang for loop that invoks th rfill() function for all th GasPump objcts in a collction calld gasStation. Do not us th auto typ spcifir.

           

Explanation / Answer

Answers:

1.a)type of parameters

2 and 3.no answer

4.it is possibl to hav mor than on dstructor in a class,but it is quite not used twice because one destructor can destroy existing constructor.

5.Yes,constructor can execute.For dynamically allocated class object constructor internally uses new operator to execute.

6.this(->) operator.

7.You could do it by collapsing your getLookupInfo -> apply some_function sequence into a single dispatch

sequence. First, lets correct your definition of some_function to reflect the fact that it is a template function:

template<typename LookupInfo>

void some_function(LookupInfo lookup)

{

vector<Record> records(Lookup_info.begin(),Lookup_info.end());

}

This is one kind of statements where lookupinfo used.

8.The function is by default an inline function.

9.Correct code should be:

class Circle

{

private:

doubl cntrX;

doubl cntrY;

doubl radius;

public:

stCntr(doubl, doubl);

stRadius(doubl);

10.copy constructor is declared as reference operator(&).

}

11.This pointer is a pointer accessible only within the nonstatic member functions of a class, struct , or union type. It

points to the object for which the member function is called.

12.copy constructor is spcial constructor, calld whn a nw objct is initializd with anothr objct’s data.

13.These are 3 cases where copy contructor has called

14.To access members of a structure, dot operator used . To access members of a structure through a pointer, arrow operator used.

15.I think this is true.

When I don't declare a constructor for example, the compiler will provide me with a default constructor that will have no arguments and no definition (body), and thus, will take no action.

If I now don't declare a destructor, the compiler will provide me with a default destructor with no defintion (body), and thus, I think no action.

16.no answer

17.No answer

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote