Question
1.
#include
2.
using namespace std;
3.
template
4.
T multIt(T x)
5.
{
6.
for(int ii = 0; ii < count; ii++)
7.
{
8.
x = x * x;
9.
}
10.
return x;
11.
};
12.
int main()
13.
{
14.
float xx = 2.1;
15.
cout
What is the output of this program?
1.
#include
2.
using namespace std;
3.
template
4.
T multIt(T x)
5.
{
6.
for(int ii = 0; ii < count; ii++)
7.
{
8.
x = x * x;
9.
}
10.
return x;
11.
};
12.
int main()
13.
{
14.
float xx = 2.1;
15.
cout
Answer: Option C
Was this answer helpful ?
In this program, We specifed the type in the template function. We need to compile this program by adding -std=c++0x.
Output:
$ g++ -std=c++0x spec1.cpp
$ a.out
2.1: 378.228
Was this answer helpful ?
Submit Solution