MCQs
Total Questions : 5
Answer: Option D. -> all of the mentioned
The compiler does not generate definitions for functions, non virtual member functions, class
or member class because it does not require instantiation.
Answer: Option A. -> pointer to member
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.
Answer: Option C. -> both a & b
It is used to adapt a policy into binary ones.
Answer: Option C. -> both a & b
Answer:d
Explanation:In this program, We are using the non-type template parameter to increment the value in the function template.
Output:
$ g++ farg4.cpp
$ a.out
2.1
3.1
4.1
Question 5.
1.
#include
2.
using namespace std;
3.
template
4.
class Test
5.
{
6.
public:
7.
Test()
8.
{
9.
};
10.
~Test()
11.
{
12.
};
13.
type Funct1(type Var1)
14.
{
15.
return Var1;
16.
}
17.
type Funct2(type Var2)
18.
{
19.
return Var2;
20.
}
21.
};
22.
int main()
23.
{
24.
Test Var1;
25.
Test Var2;
26.
cout
What is the output of this program?
1.
#include
2.
using namespace std;
3.
template
4.
class Test
5.
{
6.
public:
7.
Test()
8.
{
9.
};
10.
~Test()
11.
{
12.
};
13.
type Funct1(type Var1)
14.
{
15.
return Var1;
16.
}
17.
type Funct2(type Var2)
18.
{
19.
return Var2;
20.
}
21.
};
22.
int main()
23.
{
24.
Test Var1;
25.
Test Var2;
26.
cout
Answer: Option D. -> 2003.123
In this program, We are passing the value and returning it from template.
Output:
$ g++ farg3.cpp
$ a.out
2003.123