is this possible or desirable ever? this is sort of an open question
for instance, if i had a sports statistics input file of the format like <team name> <wins> <losses>
and i read it into three different vectors, would it make any sense to define classes if i already have the info read and stored in vectors? under what circumstances would i want to do this
this might be a vague or dumb oop question, but the context would be to run different loops analyzing the data and outputting various teams / aggregate wins or losses based on other functions
I think it would make more sense to have a class called Team that stored those three values, and then a vector of Teams.
But anyway: yeah, it's possible and often necessary to write classes that contain vectors or even more complex structures.
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
struct File{
std::string name;
Attributes attr;
};
//Note: My inheritance is rusty, so this may not make sense. If it doesn't, I'm
//probably doing it wrong.
struct Directory::File{
std::vector<File *> contents;
};
struct DirectoryTree{
Directory *root;
};
thanks helios, wow i think all of that is over my head =/ i am pretty mediocre at oop so i generally working around it when i can (habit i am trying to break)
but if i understand you correctly, you are saying make a "team" class defining <team> <wins> <losses> as their types
then read the input file into a "team" vector...
if i ran a while loop for it, would i extract with
>> team_class_name
and it would grab the input row by row then?
i will do some research so i can hopefully understand your inheritance stuff