Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Inheritance Question

Name: Anonymous 2011-11-21 12:54

Sup /prog/, self-learning programmer here. I have a question with inheritance. Say that I have a class called Food with an attribute "name" and "weight". Do I have to make subclasses with each type of food I will use (ie. apple is-a food, hence I need to make an apple subclass) or do I just instantiate a new food and call it apple? Note that I won't specifically give "apple" new attributes/methods, but I will make entities of it (ie. a person has 3 apples and 2 oranges blabla)

I realize this is a simple question but I'm a fucking baffled moron and can't seem to solve it.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List