0
Store a class somewhere so it can be deleted later?
cin salary salary stored into bank class. bank* store = new bank (); *store bank info* delete store; https://code.sololearn.com/ctK0t0Oma2uV/?ref=app
1 Réponse
+ 3
You may use a binary file to store your class data.
Open a file with ios::out|ios::binary flags, and then do:
Bankacc bac;
file.write(reinterpret_cast<char*>(&bac),sizeof(bac));
Similarly, you may open a file in read mode(ios::in|ios::binary), and read your data, using file.read(); //Same arguments
Now , to delete an object, you may use remove and rename. First create a temporary file, then write all the data in that file which you do want to restore, ignoring the one which you wish to delete. Then use remove to delete the original file. (Requires full path), and then use rename to rename the temp file to the original name so that it can be used for other operations again...