Sail E0 Webinar

MCQs

Total Questions : 5
Question 1.

How many parameters are legal for non-type template?


  1.    1
  2.    2
  3.    3
  4.    4
 Discuss Question
Answer: Option D. -> 4

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.


Question 2.

What may be the name of the parameter that the template should take?


  1.    same as template
  2.    same as class
  3.    same as function
  4.    none of the mentioned
 Discuss Question
Answer: Option A. -> same as template

None


Question 3.

Which are done by compiler for templates?


  1.    type-safe
  2.    portability
  3.    code elimination
  4.    all of the mentioned
 Discuss Question
Answer: Option A. -> type-safe

The compiler can determine at compile time whether the type associated with a template definition 

can perform all of the functions required by that template definition.


Question 4.

How many types of templates are there in c++?


  1.    1
  2.    2
  3.    3
  4.    4
 Discuss Question
Answer: Option B. -> 2

There are two types of templates. They are function template and class template.


Question 5.


What is the output of this program?


1.
#include
2.
#include
3.
using namespace std;
4.
template
5.
void print_mydata(T output)
6.
{
7.
cout
  1.    1
  2.    2
  3.    3
  4.    4
 Discuss Question
Answer: Option B. -> 2

Answer:a
Explanation:
In this program, We are passing the value to the template and printing it in the template.
Output:
$ g++ tem2.cpp
$ a.out
5.5
Hello World


Latest Videos

Latest Test Papers