[ create a new paste ] login | about

Link: http://codepad.org/aBVjROoU    [ raw code | output | fork | 1 comment ]

C++, pasted on Jun 13:
#include<stdio.h>

class Base{
public:
    double b1;
};
class Derived : public Base{
public:
    int d1;
    Base d2;
};

int main(){

    Derived* D;
    Base* B1 = new Base();  
    Base* B2= new Derived();  // B1 and B2 point to objects of different sizes
    printf("%d\n", sizeof(*D));
    printf("%d\n", sizeof(*B1));
    printf("%d", sizeof(*B2));
    return 0;
}


Output:
1
2
3
20
8
8


Create a new paste based on this one


Comments:
posted by freeboy1015 on Aug 17
the result on 32/64bit is the same:24 8 8
reply