Simple String Template

6

What is the output of this program?

1.
    #include 
2.
    using namespace std;
3.
    template 
4.
    void squareAndPrint(T x, U y)
5.
    {
6.
        cout << x << x * x << endl;
7.
        cout << y << " " << y * y << endl;
8.
    };
9.
    int main()
10.
    {
11.
        int ii = 2;
12.
        float jj = 2.1;
13.
        squareAndPrint(ii, jj);
14.
    }

a) 23

2.1 4.41

b) 24

2.1 4.41

c) 24

2.1 3.41

d) none of the mentioned


7

What is the output of this program?

1.
    #include 
2.
    using namespace std;
3.
    template 
4.
    inline T square(T x)
5.
    {
6.
        T result;
7.
        result = x * x;
8.
        return result;
9.
    };
10.
    template <>
11.
    string square(string ss)
12.
    {
13.
        return (ss+ss);
14.
    };
15.
    int main()     
16.
    {
17.
        int i = 4, ii;
18.
        string ww("A");
19.
        ii = square(i);
20.
        cout << i << ii;
21.
        cout << square(ww) << endl;
22.
    }
A. 416AA
B. 164AA
C. AA416
D. none of the mentioned

8

How to declare a template?

A. tem
B. temp
C. template<>
D. none of the mentioned

9

Pick out the correct statement about string template.

A. It is used to replace a string.
B. It is used to replace a string with another string at runtime.
C. It is used to delete a string.
D. none of the mentioned

10

What is a template?

A. A template is a formula for creating a generic class
B. A template is used to manipulate the class
C. A template is used for creating the attributes
D. none of the mentioned