adplus-dvertising
frame-decoration

Question

What is the output of this program?
    #include <iostream>
    using namespace std; 
    template<typename T>class clsTemplate
    {
        public:
        T value;
        clsTemplate(T i)
        {
            this->value = i;
        }
    void test()
    {
        cout << value << endl;
    }
    };
    class clsChild : public clsTemplate<char>
    {
        public:
        clsChild(): clsTemplate<char>( 0 )
        {
        }
        clsChild(char c): clsTemplate<char>( c )
        {    
        }
    void test2()
    {
        test();
    }
    };
    int main()
    {
        clsTemplate <int> a( 42 );
        clsChild b( 'A' );
        a.test();
        b.test();
        return 0;
    }

a.

42

b.

A

c.

42 A

d.

A 42

Answer: (c).42 A

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?