How to organize functions to save and save as (in a text editor) with the help of flags that check whether a file has been saved? Tobish, if it was not saved, then save as (via the dialog box); if it was saved, the file is silently overwritten. I don’t know anything about flags at all, I didn’t really find anything in this one. How does all this look?
- oneif you are satisfied with the answer, click (finger up) or accept it (check mark), or both - teanCH
|
1 answer
You need some kind of variable that will store the current state of the file.
For example bool flag_saved If the file is only created, then put it into a variable false, and when saving, check the value of this variable - if false, save as, if true, then overwrite. Etc...
The scope in which to insert a variable depends on the architecture of your application. This may be a global application variable (maybe even static), or if you have a file in a program organized as a separate class, this flag can be made directly in it.
|