My code builds fine but I'm getting the error:
First-chance exception at 0x00995CA7 in PcppAssingment(NG CHUNG NENG TP028902).exe: 0xC0000005: Access violation reading location 0x0124ADE4.
Unhandled exception at 0x00995CA7 in PcppAssingment(NG CHUNG NENG TP028902).exe: 0xC0000005: Access violation reading location 0x0124ADE4.
My constructors, destructors, copyconstructor and overloaded assignment operator should be correct so I have no idea why this happens.
There's something about a bad pointer, that's all I've figured out.
[i]fstream is similar to cin/cout. Use can use the operator>> (or getline(...)) to read and the operator<< to write the data like you'd do with cout/cin. Just omit the overhead.
void Activity::readacctivities(istream &is){
is >> activityid;
is >> name;
is >> type;
is >> fee;
teacherassigned.Read(is);
activitydate.Read(is);
}
void Staff::viewactivitys(){
Activity obj;
ifstream fp;
fp.open("Activity.dat",ios::binary);
obj.readacctivities(fp);
obj.displayacctivities();
cout<<"Please press ENTER to back to the menu ...";
cin.ignore();
cin.get();
}