adplus-dvertising
frame-decoration

Question

What is the output of this program?
    #include <iostream>
    using namespace std;
    template <class T>
    inline T square(T x)
    {
        T result;
        result = x * x;
        return result;
    };
    template <>
    string square<string>(string ss)
    {
        return (ss+ss);
    };
    int main()
    {
        int i = 2, ii;
        string ww("A");
        ii = square<int>(i);
        cout << i << ": " << ii;
        cout << square<string>(ww) << ":" << endl;
    }

a.

2:4AA

b.

2:4

c.

AA

d.

2:4A

Answer: (a).2:4AA

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What is the output of this program?