Questions and Answers


  1. To which type of class, We can apply RTTI?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    RTTI is available only for classes which are polymorphic, which means they have at least one virtual method.


  1. Which is used to solve the memory management problem in c++?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    smart pointers



  1. What are the operators available in dynamic memory allocation?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    new and delete operators are mainly used to allocate and deallocate during runtime.


  1. What is the output of this program?
    #include <iostream>
    #include <typeinfo>
    #include <exception>
    using namespace std;
    class BaseClass
    {
    virtual void f(){}
    };
    class DerivedClass : public BaseClass {};
    int main ()
    {
    try
    {
    BaseClass* ptr1 = new BaseClass;
    BaseClass* ptr2 = new DerivedClass;
    cout << typeid(*ptr1).name() << " ";
    cout << typeid(*ptr2).name();
    }
    catch (exception& excep)
    {
    cout << "Exception: " << excep.what() << endl;
    }
    return 0;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    In this program, We apply the typeid to the polymorphic class.



  1. What is the Run-Time Type Information?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    With the help of RTTI, We can get the information about the data type at the runtime.