Unordered_map вставить класс C++
Эй, все!!!
что я здесь делаю не так,
Тринг, чтобы передавать значение, чтобы вставить в метод класса ?
Implement a class course to manage the participants of a Course. Realize a constructor with which the title of the course can be determined; and methods for entering names and student numbers for the individual female/male students, which are identified by a number assigned to you (i.e., an index). It must be possible (through appropriate methods)
спасибо!!!
Что я уже пробовал:
<pre>#include<iostream> #include<string> #include<unordered_map> using namespace std; class Student { private: std::string name; int mrt_nr; public: void set_name(string); void set_nr(int); string get_name(); int get_mrt_nr(); }; void Student::set_name(string a) { name = a; } void Student::set_nr(int a) { mrt_nr = a; } string Student::get_name() { return name; } int Student::get_mrt_nr() { return mrt_nr; } class course { private: string titel_lehrv; unordered_map<int, std::string> st; public: course(const std::string &titel) : titel_lehrv{ titel } {}; void add( Student &a ) { st.insert(pair<int, string>(a.get_mrt_nr, a.get_name)); } }; int main() { pair<int, std::string>s1(12545, "tom"); Student st; st.set_name ("tom") ; st.set_nr (123); course mycourse(); mycourse().add(st); }
Xynosural.net
Больше информации ? что вы хотите сделать, что идет не так ?
Anas Zahed
я получаю много ошибок !!!
пытался оторваться от них, но ничего не делал.
Patrice T
а сообщения об ошибках есть ?
Anas Zahed
если я сделаю это с вектором я не получу никакой ошибки но я хочу сделать это с картой