T
tolkien
Hi!!!
I Have this:
#include<iostream.h>
class base
{
protected :
int b;
};
class derived: public base
{
private :
int d;
public:
int xxx(base k) //int xxx(derived k) works with derived
{
return b + k.b; //cannot access k.b,
}
};
Why Can't i access member b of the variable k if k is of type base?
It works fine is k is of type derived!!!
I can access b ,why can't i access k.b ??
b is protected therefore i can access it inside the derived class with
the "." operator,no?
I Have this:
#include<iostream.h>
class base
{
protected :
int b;
};
class derived: public base
{
private :
int d;
public:
int xxx(base k) //int xxx(derived k) works with derived
{
return b + k.b; //cannot access k.b,
}
};
Why Can't i access member b of the variable k if k is of type base?
It works fine is k is of type derived!!!
I can access b ,why can't i access k.b ??
b is protected therefore i can access it inside the derived class with
the "." operator,no?