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

zubairjam's Avatar, Join Date: Oct 2010
Newbie Member
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

Last edited by shabbir; 3Oct2010 at 18:59.. Reason: Code blocks
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
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).
shabbir like this