Home » C++ Programming » Templates » Question
  1. What is the output of this program?
    #include <iostream>
    using namespace std;
    class classA
    {
    public:
    virtual ~classA(){}
    protected:
    char p;
    public:
    char getChar();
    };
    class classB : public classA
    {
    public:
    void printChar();
    };
    void classB::printChar()
    {
    cout << "False" << endl;
    }
    int main()
    {
    classB ch;
    ch.printChar();
    return 1;
    }
    1. True
    2. False
    3. Runtime Error
    4. Compilation Error
    5. None of these
Correct Option: B

In this program, We are passing the values and inheriting it to the other class and printing the result.



Your comments will be displayed only after manual approval.