I am trying to tell the program that cow's under 1 year old and over 10 years old do not, produce milk.
The equation or formula or whatever you want to call it is in the .cpp at the bottom.
When you're asking for help, it's common courtesy and common sense to tell us how "it's not working". Do you get compilation errors? Do you get run-time errors? Is the program behaving unexpectedly? Keep that in mind next time you ask a question.
As for your problem - fortunately, it's an easy one.
The Cow class doesn't have any members named "age", "weight" or "food", so how do you expect line 11 in Cow.cpp to work? Even if the Cow class had those members, the way you're trying to access them makes very little to no sense.
Ah that is because they are variables initialized in the parent class DairyAnimal. DairyAnimal.h is included in this class.
What I need to happen is for the cows age to factor into the call to the member function milk(), which is a overload function for milk() in the DairyAnimal class.
If it will help I will put the DairyAnimal class code in here, I just figured this answer could go without it.
I'm sorry, I wasn't paying attention in my previous post.
The problem is on line 11 of your cow.cpp file.
The if control structure looks like this:
if(Cow().age >= 1 && Cow().age <= 10)
However, there's a problem - Cow().age is accessing the age member of a temporary Cow object, not of the actual cow you think whose age you're requesting. Since this temporary cow hasn't been explicitly initialized with an age, the age will be set to 1, as the DairyAnimal class default value indicates.