Objects with inheritance memory storage

Posted by nikitas350 on Stack Overflow See other posts from Stack Overflow or by nikitas350
Published on 2011-01-29T14:49:45Z Indexed on 2011/01/29 15:26 UTC
Read the original article Hit count: 136

Filed under:

Say that i have some classes like this example.

class A {
     int k, m;
public:
     A(int a, int b) {
          k = a;
          m = b;
     }
};

class B {
     int k, m;
public:
     B() {
          k = 2;
          m = 3;
     }
};

class C : private A, private B {
     int k, m;
public:
     C(int a, int b) : A(a, b) {
          k = b;
          m = a;
     }
};

Now, in a class C object, are the variables stored in a specific way? I know what happens in a POD object, but this is not a POD object...

© Stack Overflow or respective owner

Related posts about c++