Multiple choice

What is the output of the following program? Assume sizeof(int) = 4

#include <iostream> using namespace std;

class Base { static int b; }; class Derived : public Base { int d; }; int main() { Derived objD; cout << sizeof(objD) << endl; }

  1. 4

  2. 8

  3. 5

  4. 12

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

Static variables are not inherited. Therefore, sizeof(objD) = sizeof(d)