i have a string object in map object which is in a class object then it is giving me error what to do
#include <iostream>
#include <fstream>
#include <map>
#include<cstring>
using namespace std;
class student
{
public:
    int rollno;
    char name[50];
    int sub[10];
    map<string, int> marks;
};
int main()
{
    int totalsub;
    student st;
    st.rollno=21;
    strcpy(st.name,"Aman Tiwari");
    cout << "enter total subject :";
    cin >> totalsub;
    for (int i = 0; i < totalsub; i++)
    {
        int num;
        string str;
        cin.ignore();
        cout << "enter " << i << " subject name :";
        getline(cin,str);
        cout << "enter marks:";
        cin >> num;
**        st.marks.insert(pair<string, int>(str, num));**
    }
    // cout << "total data is :" << endl;
    // for (auto &mark : st.marks)
    // {
    //     cout << mark.first << " " << mark.second << endl;
    // }
    ofstream ofobj;
    ofobj.open("test.dat",ios::binary|ios::app);
    ofobj.write(reinterpret_cast<char*>(&st),sizeof(student));
    ofobj.close();
    ifstream ifobj;
    ifobj.open("test.dat", ios::binary | ios::in);
    student temp;
    ifobj.read(reinterpret_cast<char *>(&temp), sizeof(student));
    cout << " the data is " << endl;
    cout << temp.rollno<<endl;
    cout << temp.name<<endl;
    for (auto &mark : temp.marks)
    {
        cout << mark.first << " " << mark.second << endl;
    }
    cout<<"After showing !!";
    return 0;
}
this problem is occured due to string object in class object and map object doesn't stores character array otherwise i will be able to store student object in file containing map of string and int.
 
    