Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

What is a pure virtual function?

0
Posted

What is a pure virtual function?

0

A9. “A pure virtual function is a function declared in a base class that has no definition relative to the base.” Q10. What is an abstract base class? A10. It is a class that has one or more pure virtual functions. Q11. What is the difference between MyClass p; and MyClass p();? A11. MyClass p; creates an instance of class MyClass by calling a constructor for MyClass. MyClass p(); declares function p which takes no parameters and returns an object of class MyClass by value. Q12. How do you know that your class needs a virtual destructor? A12. If your class has at least one virtual function, you should make a destructor for this class virtual. This will allow you to delete a dynamic object through a pointer to a base class object. If the destructor is non-virtual, then wrong destructor will be invoked during deletion of the dynamic object. Q13. Why were the templates introduced? A13. Many data structures and algorithms can be defined independently of the type of data they work with. You

0

A pure virtual function is a function that must be overridden in a derived class and need not be defined. A virtual function is declared to be “pure” using the curious “=0” syntax.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123