Q) Overloaded functions in C++ oops are
  1. Functions preceding with virtual keywords.
  2. Functions inherited from base class to derived class.
  3. Two or more functions having same name but different number of parameters or type.
  4. None of above

Answer: 3
Function overloading is compile time polymorphism in which 2 or more functions share the same name with different arguments and parameters in C++ oops.
Recommended to read function overloading in C++

NOTE: In C++, constructor is also a special type of function that can be overloaded. You can read advantage of constructor overloading in C++ applications.


Q) Correct way to declare pure virtual function in a C++ class is
  1. virtual void foo() =0 ;
  2. void virtual foo()= { 0 }
  3. virtual void foo() {} = 0;
  4. None

Answer: 1
A is the correct declaration of pure virtual function in a class in C++.
NOTE: Pure virtual function is used in an Interface or an abstract class.
Read details about C++ pure virtual function , C++ Interface and How to create abstract class in C++ program


Related Posts