C++ Interview Question and Answers

36. What is the difference between a template class and class template?
  Template classA generic definition or a parameterized class not instantiated until the client provides the needed information. It’s jargon for plain templates.
Class templateA class template specifies how individual classes can be constructed much like the way a class specifies how individual objects can be constructed. It’s jargon for plain classes.
 
Your Name Your Email-ID
Your Answer
37. What is friend function?
 
  • The function declaration should be preceded by the keyword friend.
  • The function definitions does not use either the keyword or the scope operator ::
  • The functions that are declared with the keyword friend as friend function.
  • Thus, a friend function is an ordinary function or a member of another class.
 
Ritesh, says Jan 30,2014
A friend function is a function that is not a member of a class but has access to the class’s private and protected members.
Your Name Your Email-ID
Your Answer
38. What is a scope resolution operator?
  A scope resolution operator (::), can be used to define the member functions of a class outside the class.
 
Your Name Your Email-ID
Your Answer
39. What do you mean by pure virtual functions?
  A pure virtual member function is a member function that the base class forces derived classes to provide. Any class containing any pure virtual function cannot be used to create object of its own type.
 
Your Name Your Email-ID
Your Answer
40. What is a conversion constructor?
 
  • A converting constructor is a single-parameter constructor that is declared without the function specifier explicit.
  • The compiler uses converting constructors to convert objects from the type of the first parameter to the type of the converting constructor’s class.
 
Sourav, says Jan 04,2014
If a class has a constructor which can be called with a single argument, then this constructor becomes conversion constructor because such a constructor allows automatic conversion to the class being constructed.
Your Name Your Email-ID
Your Answer