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

Questions: The following few questions involved the classes diagrammed below: Pa

ID: 3677567 • Letter: Q

Question

Questions:

The following few questions involved the classes diagrammed below:

Parent Class

Subclass

Subclass

Class Parent

virtual void foo();
virtual void bar() = 0;
void func1();
protected:
int ParentProtected;
private:
double ParentPrivate;
};

Class Child

void foo( );
void func2();
virtual void bar();
protected:
int ChildProtected;

};

Class GrandChild

virtual void bar();
virtual void foobar();
private:
int GrandChildPrivate;

};

Based on the classes shown above, the next few questions relate to the following declarations shown below:

Child instanceofChild;
Child * ptrChild = &instanceofChild;
GrandChild instanceofGChild;
GrandChild * ptrGrandChild = &instanceofGChild;

1. The keyword friend on a method appears in the: .h file .cpp file 2. The keyword const on a class method appears in the: .h file .cpp file 3. The keyword const on a class method parameter appears in the: .h file .cpp file 4. The keyword virtual applied to a class method appears in the: .h file .cpp file 5. Unless implemented by the class author to do something different, a copy-constructor performs member-wise copying of the member variables in a class. True False 6. A copy constructor gets invoked whenever a class method returns a classtype variable. True False 7. If marked as friend, can the overloaded operator>> also be marked as aconst method of a class? Yes No 8. If marked as friend, can the overloaded operator- also be marked as aconst method of a class? Yes No 9. If marked as friend, can the overloaded operator< also be marked as aconst method? Yes No 10. Once a method is marked virtual in a class hierarchy, every other version of that method in all of its subclasses will also be treated asvirtual . True False

Explanation / Answer

1).h file and .cpp file

2).h file and .cpp file

3).h file and .cpp file

4).h file and .cpp file

5)true

6)false

7)no

8)No

9)No

10)True

11)Yes

12)No

13)No

14)yes

15)yes

16)yes

17)yes

18)no

19)no

20)no

21)yes

22)no

23)n0

24)no

25)no

26)yes

27)yes

28)no

29)no

30)Child's version

31)GrandChild's version

32)Child's version

33)GrandChild's version

34)no one called because dot(.) operator is used insted of ->