C++ Interview Question and Answers

21. What is the difference between macro and iniine?
  Inline follows strict parameter type checking, macros do not.
Macros are always expanded by preprocessor, whereas compiler may or may not replace the inline definitions.
 
Vaishu,says Mar 27, 2014
Macros are replaced by its definition by the pre-processor where as in inline function the code of the function replaces the function call when the function is invoked during compilation of the code.
Aditi,says Feb 03,2014
Inline function can not be edited and macros can be edited.
Your Name Your Email-ID
Your Answer
22. How variable declaration in c++ differs that in c?
  C requires all the variables to be declared at the beginning of a scope but in c++ we can declare variables anywhere in the scope. This makes the programmer easier to understand because the variables are declared in the context of their use.
 
Your Name Your Email-ID
Your Answer
23. What is multiple inheritance?
  A class can inherit properties from more than one class which is known as multiple inheritance.
 
Asutosh ,says June 25,2018
A class which inherit from a number of classes is known as multiple inheritance.
Your Name Your Email-ID
Your Answer
24. what is the use of virtual destructor in c++?
 
  • A destructor is automatically called when the object is destroyed.
  • A virtual destructor in C++ is used primarily to prevent resource leaks by performing a clean-up of the object.
 
Sruthi, says Feb 04,2014
Virtual destructors are useful when you can delete an instance of a derived class through a pointer to base class.
Your Name Your Email-ID
Your Answer
25. What do you mean by reference variable in c++?
  A reference variable provides an alias to a previously defined variable.
Data -type & reference-name = variable name
 
Your Name Your Email-ID
Your Answer