Can I pass a structure to map in STL?
I've created a structure as:
struct info
{
std::string name;
std::string registration_number;
std::string roll_number;
std::string mother_name;
std::string father_name;
int contact_number;
std::string address;
};
Here's my program so far:
class Attendance_Management_System
{
private:
std::multimap<std::string ,info> mymap;
public:
void register_a_new_student();
};
void Attendance_Management_System::register_a_new_student()
{
std::cout<<"Name of the Student \t Registration Number \t Roll Number \t Mother's Name \t Father's Name \t Contact Number \t Address \n\n";
//Here I want my map to take all the inputs and save it in the map
}
How do I go about approaching this problem? I tried overloading stream operators but that didn't work. I Searched around and found out that I had to define < operator or had to create a function comparator but still I'm too confused as what to do.
After this I also want to create a function which will output the contents in the map. Will simple iterator work in that or will I have to overload something else also.
Aucun commentaire:
Enregistrer un commentaire