C++ Access Violation while Reading from File -


Just started at C ++

I get access violation errors while reading from the binary file. Here are the classes included:

  class staff {// base class public: staff () {} Virtual Employee {}}  

One of these Derived Classes:

  Class Scheduler: Public Employee {Public: Scheduler () {} // Define Any Destruction}  

and then the code in the code using these codes:

  ifstream in ("Scheduler.dat", ios :: in | ios : En: Basic); Scheduler; In.read (reinterpret_cast & lt; char * & gt; (& s), sizeof (scheduler));  

The moment I read the statement, the access violation exception triggered, and points for the virtual ruin in the VS 2013 class staff.

Is it because I have not clearly created a destructor in class scheduler? Or is it something else?

scheduler is not a trivially copyable class, Can not read from or write it.

An articulately classified class is

  1. A non-trivial Constructor is not
  2. There is no non-comparable copy structure
  3. Any non-trivial copy constructor ( does not require any virtual functions or virtual grounds
  4. An appetite killer operators

You must remove either the virtual detector (if you have staff polymorphically If you want to use it, bring yourself on your own issues), read a file using a serialization library, or write your own serialization function, how canonical like std :: ostream & amp; ; Operator & lt; & Lt; (Std :: ostream & amp; Staff Staff & amp;;);


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -