Home » C++ Programming » Inheritance » Question
  1. What is the output of this program?
    #include <iostream>
    using namespace std;
    struct Student1
    {
    int num;
    };
    struct Student2
    {
    int* val;
    };
    struct Student3 : public Student1, public Student2
    {
    };
    int main()
    {
    Student3* ptr = new Student3;
    ptr->val = 0;
    cout << "Above structures are Inherited...";
    return 0;
    }
    1. Compilation Error
    2. Runtime Error
    3. Above structures are Inherited...
    4. Garbage value
    5. None of these
Correct Option: C

In this program, We apply the multiple inheritance to structure.



Your comments will be displayed only after manual approval.