Home » C++ Programming » Templates » Question
  1. What is the output of this program?
    #include <iostream>
    #include <string>
    using namespace std;
    template<typename T>
    void Print_Data(T output)
    {
    cout << output << endl;
    }
    int main()
    {
    double var = 6.25;
    string str("Hello Interview Mania");
    Print_Data( var );
    Print_Data( str );
    return 0;
    }
    1. Hello Interview Mania
    2. Hello Interview Mania
      6.25
    3. 6.25
      Hello Interview Mania
    4. Compilation Error
    5. None of these
Correct Option: C

In this program, We are passing the value to the template and printing it in the template.



Your comments will be displayed only after manual approval.