Home Interview Questions and AnswersTechnical Interview Questions and AnswersC++ Latest C++ Interview Questions and Answers Part-3

c++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.

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.

23. What is multiple inheritance?

A class can inherit properties from more than one class which is known as multiple inheritance.

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.

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

26. What is iterator class?

Iterator class provides an access to the class which are inside the containers(it holds a group of objects in an organized way).
The containers include the data structure, class and abstract data type.

27. What are the types of declarations in C++?

There are so many types of declaration in C++ are :
Variable declaration
Constant declaration
Function declaration
Object declaration

28. What are Smart pointers?

Smart pointers are almost similar to pointers with additional features such as automatic destruction of a variable when it becomes out of scope and the throwing of exceptions that ensures the proper destruction of the dynamically allocated objects.

29. Explain function template?

Function template provides a means to write generic functions for different data types such as integer, long, float or user defined objects.

30. Explain class template?

Class template provides a means to write a generic class for different types so that a class can have members based on generic types that do not need to be defined at the moment of creating the class or whose members use these generic types.

You may also like

Leave a Comment