How can i access a public data member of a derived class with a pointer to the base class.
class Base
{
public:
Base(){};
virtual ~Base(){};
virtual bool decode(AOC_Stri ng element_text) ;
}
class Derived: pubilc Base
{
pubilc:
int ele;
bool decode(AOC_Stri ng element_text)
{
}
}
Base *Ptr = (Base *)new(Derived);
Ptr->decode("123" ); //works fine
Ptr->ele; //this throws an error... why is this wrong, what's the right way
Many Thanks
class Base
{
public:
Base(){};
virtual ~Base(){};
virtual bool decode(AOC_Stri ng element_text) ;
}
class Derived: pubilc Base
{
pubilc:
int ele;
bool decode(AOC_Stri ng element_text)
{
}
}
Base *Ptr = (Base *)new(Derived);
Ptr->decode("123" ); //works fine
Ptr->ele; //this throws an error... why is this wrong, what's the right way
Many Thanks
Comment