When I try to compile my code, I get an error about there not being a match for cout 'operator<<'. As I'm new to C++, I don't know what the problem is. In other programs, I've been able to print the contents of vectors using a loop like this. What exactly am I doing wrong?
The problem is that you have a vector of StudentProfiles, but std::cout has no idea how to print out that structure. You'll need to tell it how to do it somehow, probably by defining your own operator << for it.
There is a question of the design too. Why would an individual StudentProfile have a print function which deals with a vector of StudentProfiles? It's as if one individual student is expected to handle the data for all of the other students.
I haven't been taught how to define operators. I'm currently researching how to do that, but I'm having a hard time understanding. As far as the design goes, that's the template my lab instructor gave us. You're right, it doesn't quite make sense, so I've pulled that out of the class.
Just a lil addition to giblit's comment, to use his overloaded operator<< you have to make it a friend of your class, otherwise the class would not give any access to its private data member(unless of course your data members are public).
My classes are public for this project. I've tried using the syntax provided above, but I'm still getting compile errors. I've spent over four hours trying to figure this out. Any specific examples related to my code?