
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C++ interview questions on virtual function and abstract class
What is a virtual function?
A virtual function is a method that does not have a definition when defined in the base class. This method is left black in the parent class and it is redefined in the child class.
What is an abstract class?
An abstract class is a class that has abstract members or at least one pure virtual function in its definition. An abstract class can never be instanced (creating an object). It can only be inherited and the methods could be overwritten.
Can there be any virtual Destructors?
Yes, These are legal in C++, but these are destructors are for base class instead of the child class.
Does every virtual function need to be overridden?
No, It is not always mandatory to redefine a virtual function. It can be used as it is in the base class.
Can we have a constructor as Virtual?
Constructors cannot be virtual, because they need to be defined in the class.
- Related Questions & Answers
- Java Interview Questions on Constructors
- C++ Interview questions based on constructors/ Destructors
- Java interview questions and answers
- Commonly Asked C++ Interview Questions
- Best Java interview questions
- Core Java interview questions
- Galaxe Solutions Interview Questions
- Pure Virtual Functions and Abstract Classes in C++
- Top QA Interview Questions & Answers
- Any good resource for java interview questions
- How to answer Top Java interview questions
- Top Automation Testing Interview Questions & Answers
- Top Database Testing Interview Questions & Answers
- Top Software Testing Interview Questions & Answers
- What is the difference between virtual and abstract functions in C#?
Advertisements