I am learning about inheritance and I am a bit confused by one of the problems I got. In this problem, why is the output The color is orange
and not The color is orangeThecolor is red
?
using namespace std;
class Red{
public: void print(){
cout<<"The color is red";
}
};
class Orange: public Red{
public: void print(){
cout<<"The color is orange";
}
};
class Yellow: public Orange{};
int main()
{
Orange colorOrange;
colorOrange.print();
return 0;
}