inheritance-

Write your question here.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
  #include <iostream>
using namespace std;
class A
{
private:
    int a;
};
class B:public A
{
private:
    int j;
};
int main()
{
    cout<<sizeof(B);
}

my doubt is .. y is sizeof class B coming out to b 8 when B contains only 1 integer data member as data member of A wont be inherited coz its private
Last edited on
Private members do get inherited. They just can't be accessed directly outside of the class they are declared in.
Topic archived. No new replies allowed.