Home » C++ Programming » Templates » Question
  1. What is the output of this program?
    #include <iostream>
    using namespace std;
    template <class type>
    class Example
    {
    public:
    Example();
    ~Example();
    type Data(type);
    };
    template <class type>
    type Example<type>::Data(type Value0)
    {
    return Value0;
    }
    template <class type>
    Example<type>::Example()
    {
    }
    template <class type>
    Example<type>::~Example()
    {
    }
    int main(void)
    {
    Example<char> Value1;
    cout << Value1.Data('L') << endl;
    return 0;
    }
    1. Compilation Error
    2. Runtime Error
    3. Garbage Value
    4. L
    5. None of these
Correct Option: D

In this program, We are passing the values and printing it by using template inheritance.



Your comments will be displayed only after manual approval.