Templates


  1. Which value is placed in the base class?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    We can place the default type values in a base class and overriding some of them through derivation.


  1. Which is dependant on template parameter?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    base class



  1. What is another name of full specialization?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    explicit specialization


  1. How many types of specialization are there in c++?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    There are two types of specialization. They are full specialization and partial specialization.



  1. What is the output of this program?
    #include <iostream>
    using namespace std;
    template<class T = float, int k = 5> class N
    {
    public:
    N();
    int value;
    };
    template<> class N<>
    {
    public: N();
    };
    template<> class N<double, 10>
    {
    public: N();
    };
    template<class T, int k> N<T, k>::N() : value(k)
    {
    cout << value;
    }
    N<>::N()
    {
    cout << " Out of ";
    }
    N<double, 10>::N()
    {
    cout << "10" << endl;
    }
    int main()
    {
    N<int, 8> x;
    N<> y;
    N<double, 10> z;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    In this program, We are defining three templates and specializing it and passing the values to it and printing it.