Consider the following class and answer the questions 1 class myClass { 2 Privat
ID: 3866190 • Letter: C
Question
Consider the following class and answer the questions 1 class myClass { 2 Private: 3 double a: 4 double b: 5 double c: 6 Public: 7 myClass(double x, double y, double z) { 8 a = x: 9 b = y: 10 c = z: 11 } 12 double average () { 13 return (a + b + c)/3.0: 14 { 7.a Write the function prototype of average. Answer: 7.b Modify average to make it constant function Answer: 7.c Modify average to make it virtual. Answer: 7.d Modify average to make it pure virtual. Answer: 7.e Modify average to make it constant and pure virtual. Answer:Explanation / Answer
7. c) Must be declared in public section of class.
virtual double average()
{
return (a+b+c)/3.0;
}
7.d ) "Pure Virtual Function is a Virtual function with no body"
A pure virtual function is a virtual function whose declaration ends in =0
7.e) To declare a constant member function, place the const keyword after the closing parenthesis of the argument list
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.