I will never understand why schools teach file streams before things like vectors or at the same time as classes or other data structures /rant
Okay, so in your prompt you said that Each line in your art.dat has a struct called Size.
Doing
Size size(height, width);
would construct a variable named "size" of type Size with the given height and width.
When I first read the prompt I assumed that those things had already been made for you.
You have to define your own struct called Size, and give it a height and width property.
http://www.cplusplus.com/doc/tutorial/structures/
Note that a struct doesn't need to have a constructor, you can just do something like
1 2 3 4 5 6 7 8 9 10
|
struct Size {
int width;
int height;
} ;
///in your main program:
Size size;
f >> size.height;
f >> size.width;
|
I'm not sure what you already know so sorry if my posts seem disorganized.
About the art_data variable: It's an std::vector. Here's how you would make it if it's just an array
1 2 3 4 5
|
Art art_array[120];
...
//for loop
Art art(artist, title, medium, size, etc.);
art_array[i] = art;
|
If you're just using structs and don't want to use a constructor, do something like
1 2 3 4 5 6
|
Art art_instance;
f >> art_instance.artist;
f >> art_instance.title;
f >> art_instance.medium;
...
art_array[i] = art_instance;
|
Ignore the vector code you don't need to use vectors, arrays are fine, don't want confuse you anymore than I have...