What will be the output of the following C++ code? [code] #include <iostream> using namespace std; template<typename T>class

Man Ly

New member
What will be the output of the following C++ code?
Code:
    #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
 

Tìm kiếm

Back
Top