C++ Interview Question and Answers

66. What are static members and static functions?
 
    Static members are
  • Created and initialized only once.
  • Shared among all the class objects.
  • Static functions are
  • Similar to the static variables and are associated with the class.
  • Can only access static variables of a class.
  • Can also be called using the scope resolution operator.
 
Your Name Your Email-ID
Your Answer
67. What are the components of a class?
  A class consists of two components,
  • Data members
  • Methods
 
Your Name Your Email-ID
Your Answer
68. What is the advantage of using templates?
 
  • Templates provide a means to write generic functions and classes for different data types.
  • Templates are sometimes called parameterized types.
  • Templates can significantly reduce source code size and increase code flexibility without reducing type safety.
 
Your Name Your Email-ID
Your Answer
69. Can a function overloading depend only on passing by value and passing by reference?
  No, the reason is that whether a function is called the passing a parameter as a value or by reference, it appears similar to the caller of the function.
 
Your Name Your Email-ID
Your Answer
70. Is it possible to use a new for the reallocation of pointers?
  The reallocation of pointers cannot be done by using new. It can be done by using the realloc() operator.
 
Your Name Your Email-ID
Your Answer