Question

8. Virtual function is class function which expected to be redefined in class, so that when reference is made to derived clas
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer: The correct answer is option a "Base, Derived, Derived"

Virtual function: A virtual function is a  base class function which expected to redefine in the derived class, so that when a reference is made to a derived class object using pointer then we call the virtual function to execute derived class definition version.

Add a comment
Know the answer?
Add Answer to:
8. Virtual function is class function which expected to be redefined in class, so that when...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 8. Suppose class D is derived from class B, and class B has a public member...

    8. Suppose class D is derived from class B, and class B has a public member function that is virtual whose declaration is virtual void fO:, and another publie member function that is not virtual whose declaration is void g):. Suppose class D has its own version of the two functions void 1() and void gO. Here below is a pointer definition and access to the member functions f) and gO Suppose this is embedded in an otherwise correct and...

  • Suppose the base class and the derived class each have a member function with the same...

    Suppose the base class and the derived class each have a member function with the same signature. When you have a pointer to a base class object and call a function member through the pointer, discuss what determines which function is actually called—the base class member function or the derived-class function.

  • A virtual function is called using a reference to a base class. Discuss if the function...

    A virtual function is called using a reference to a base class. Discuss if the function in base class is called or the function in the derived class and why?

  • Question 3: Q3 (Polymorphism & virtual function) a) Consider the class, derived class, and the virtual functions as shown in Display for Q3. Create a derived class (of Sale) called 'Mailorder...

    Question 3: Q3 (Polymorphism & virtual function) a) Consider the class, derived class, and the virtual functions as shown in Display for Q3. Create a derived class (of Sale) called 'MailorderSale' having one private member variable called 'shipping charge'. It should have constructor function and virtual function 'bill' (this function adds shipping charge to the price). Define all these functions (no need of default constructors). b) In the main function, define one object of DiscountSale with (11,10) initial values and...

  • In Exercise 1, displayAnimal uses an Animal reference variable as its parameter. Change your code to...

    In Exercise 1, displayAnimal uses an Animal reference variable as its parameter. Change your code to make the displayAnimal function anim parameter as an object variable, not a reference variable. Run the code and examine the output. What has changed? Polymorphic behavior is not possible when an object is passed by value. Even though printClassName is declared virtual, static binding still takes place because anim is not a reference variable or a pointer. Alternatively we could have used an Animal...

  • This is In C++ only Thank you 2. Employee is a base class and Hourly Worker...

    This is In C++ only Thank you 2. Employee is a base class and Hourly Worker is a derived class. Which statement about the destructors of both classes is true? al They should be declared virtual u Declaring them virtual or not does not make any difference c) They should be implemented as friend functions d) The destructor of HourlyWorker must be virtual whereas the destructor of Employee should 3. If a base class has a non-virtual member function called...

  • please write the code in C++ 2 Base class File 3 Derived class PDF 3.1 Class...

    please write the code in C++ 2 Base class File 3 Derived class PDF 3.1 Class declaration • The class PDF inherits from File and is a non-abstract class 1. Hence objects of the class PDF can be instantiated. 2. To do so, we must override the pure virtual function clone) in the base class • The class declaration is given below. • The complete class declaration is given below, copy and paste it into your file. . It is...

  • I do not understand the output when using dog.print() Can you explain what happens when Dogtype...

    I do not understand the output when using dog.print() Can you explain what happens when Dogtype dog("Tommy", "German....."); and dog.print() executes. This is c++ For classes 1. Include the destruc 2. 3. Include the copy constructor. tor in lI Overload the assignment operator for the class r 13 discusses overloading the assignment operator. Until Chapte discuss classes with pointer member variables, out of the three iten we will implement only the destructor and the copy constructor. Inheritance, Pointers, and Virtual...

  • 27. Suppose the unary ! operator is an overloaded member function of class String. For a...

    27. Suppose the unary ! operator is an overloaded member function of class String. For a String object s, which function call is generated by the compiler when it finds the expression Is? a. s.operator!0 b. s.operator!(default valuel, default value?,...) c. operator!(s d. A compiler error results because no arguments are given 28. Select the false statement regarding inheritance. a. A derived class can contain more attributes and behaviors than its base class b. A derived class can be the...

  • please write in c++. 4 Derived class JPG 4.1 Class declaration • The class JPG inherits...

    please write in c++. 4 Derived class JPG 4.1 Class declaration • The class JPG inherits from File and is a non-abstract class. 1. Hence objects of the class JPG can be instantiated. 2. To do so, we must override the pure virtual function clone() in the base class. • The class declaration is given below. class JPG : public File { public: JPG(const std::string& n, int n, int w, const double rgb()) : File(...) { // ... } *JPG()...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT