Which type of function cannot be virtual in C++?
- Inline functions
- Constructor functions
- Friend functions
- Static member functions
Constructors in C++ cannot be virtual. When creating an instance of a derived class, it's essential to know the exact type of the object being created, so the correct constructor gets called. Making constructors virtual doesn't make sense in the context of object-oriented design, as it would introduce ambiguity in the object creation process.
Loading...
Related Quiz
- When an array is passed to a function, it is always passed by _______.
- In what scenario might a weak_ptr be particularly useful to prevent?
- In tail recursion, the recursive call is the _______ action to be performed in the function.
- How does pass by reference in C++ handle underlying memory allocation?
- The keyword _______ is used to specify that a function should be compiled inline.