LogiQuest
Back to Inheritance
7

What will be the output of the program?

#include <iostream>
using namespace std;
class A { public: int x = 1; };
class B : public A { public: int y = 2; };
int main() {
    B b;
    cout << b.x + b.y << endl;
    return 0;
}
Easy

Discussion (0)

  • No discussion yet. Ask a doubt or share a shortcut.

Log in to join the discussion.