C
carl
I have a base class with a protected field. I have created a subclass where
I would like to access and use this protected field:
// Base class
class R {
protected:
std::string image_path;
};
// Subclass
class L : public R {
public:
void test(){
std::cout << image_path << std::endl;
}
};
But that is a no go, it complains that the image_path field is unknown. In
the book Accelerated C++ pp 229 it says that subclasses can see protected
fields from the base class so what is wrong with the above?
I would like to access and use this protected field:
// Base class
class R {
protected:
std::string image_path;
};
// Subclass
class L : public R {
public:
void test(){
std::cout << image_path << std::endl;
}
};
But that is a no go, it complains that the image_path field is unknown. In
the book Accelerated C++ pp 229 it says that subclasses can see protected
fields from the base class so what is wrong with the above?