I'm playing around with Vectors, trying to better my knowledge of them.
I created (i think) an empty vector: vector<string> contents;
I created (i think) an accessor method: vector<string> getContents();
The method looks like this:
vector<string> Album::getContents()
{
cout << "\nAlbum Contents:\n\n" << endl;
for(vector<string>::iterator iter = contents.begin();
iter !=contents.end(); iter++)
{
cout << *iter << endl;
}
}
Is this a suitable accessor method or am I over thinking something? Because my getContents
doesn't return anything but prints it instead...
Assuming this is a valid method, what would be a better way to return the contents of a vector collection? Thanks.
Edit: I've just compiled it and my method needs to return something... So now im assuming my method is pointless and you should be able to return the vectors collection item by item similar to a Java array using a for-loop? I dunno.