Q: What is the syntax of class template?
Solution: Syntax involves template keyword followed by list of parameters in angular brackets and then class declaration. As follows templateclass declaration;
Q: How the template class is different from the normal class?
Solution: Size of the object of template class varies depending on the type of template parameter passed to the class. Due to which each object occupies different memories on system hence saving extra memories. Template class also helps in making generic classes.
Q: How many template parameters are allowed in template classes?
Solution: Just like normal parameters we can pass more than one or more template parameters to a template class.
Q: What is meant by the template parameter?
Solution: A template parameter is a special kind of parameter that can be used to pass a type as argument.
Q: Which keyword can be used in template?
Solution: Both keywords can be used as shown below: templatefunction declaration; template function declaration;
Q: What is the validity of template parameters?
Solution: Template parameters are valid inside a block only i.e. they have block scope.
Q: Why we use :: template-template parameter?
Solution: It is used to adapt a policy into binary ones.
Q: Which parameter is legal for non-type template?
Solution: The following are legal for non-type template parameters:integral or enumeration type, Pointer to object or pointer to function, Reference to object or reference to function, Pointer to member.
Q: Which of the things does not require instantiation?
Solution: The compiler does not generate definitions for functions, non virtual member functions, class or member class because it does not require instantiation.
You Have Score    | /9 |