When you create a class that is also a part of another class
class dog : class animal
Then dog has access to all that animal has BUT animal does not have acces to all that dog has. Think of it this way.
1 2 3 4 5 6 7 8 9 10
|
class animal
{
void breathe;
};
class dog : animal
{
void Bark;
void WagTail;
};
|
Now in this very crude and basic example, class animal is set up to only breathe. All animals breathes in this program's world. Now a dog is an animal, but it does a lot more. So a dog case Bark and Wag its little or huge tail, but it still can also breathe since it is also an animal. It is like dog was created like this:
1 2 3 4 5 6
|
class dog
{
void breathe;
void Bark;
void WagTail;
}
|
Both the codes basically say the same thing. Hopefully this helps you to understand. The term for this is class inheritance.
Now if you have the same variables or functions in dog and animal, it will run the one in Dog first, but you will have potential problems if you are not careful like you have. You used the same exact variables in Entree and Italian, so if a function is only part of Entree, then it can not access the variables in Italian but Italian can access both Italian's variables and Entree's variables. Since it has the choice, it will always choose Italian first though so since the function you ran could only access the Entree, it changed that but when you wanted a display, it has access to the Italian variables.
An easier way to say it, take out every variable in Italian that is also in Entree since Italian can use those variables without a problem. That will eliminate your problems.