This is a theoretical question, I haven't figured a straight well explained answer yet, about object oriented design. Let's say we have a class of a Music Event, and we would like to implement a Rating class with maybe one int member(stars 1-5) and maybe one getter and one setter function. Maybe I haven't thought some bigger picture yet?
If we want our Music Event class to have ratings (just one not an array), why is it better -if it is- to inherit from the Rating class, and not to add a Rating class member inside the Music event class?
in coding:
//why is this better...
class MusicEvent:public Rating {
string name;
string duration;
//and other stuff here
}
//...than this
class MusicEvent {
string name;
string duration;
Rating rating;
//and other stuff here
}