Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   data member of base class but not of derive class..why? (http://www.go4expert.com/forums/data-base-class-derive-classwhy-t23476/)

zubairjam 3Oct2010 18:46

data member of base class but not of derive class..why?
 
Code:

int main()
{
    D d;
    cout<<"size of d: "<<sizeof(d)<<endl;//8
    cout<<"i: "<<d.i<<endl;//error
    return 0;
}

error: i is not member of D.
but D is derived from B...i is in public part then why this
error :thinking::thinking::thinking:

xpi0t0s 4Oct2010 12:11

Re: data member of base class but not of derive class..why?
 
How can we debug code that you don't post?

You're right though: it SHOULD work. So we need to see the code to find the problem.
Try to cut B and D down to the least possible (ideally just the i definition).


All times are GMT +5.5. The time now is 18:08.