Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- class file {
- private:
- fstream data_file;
- public:
- file (const char* filename) {
- data_file.open(filename);
- if (!data_file.is_open()) {
- throw("file open failure");
- }
- }
- ~file() {
- if (!data_file.is_open()) {
- cout << "Destructor was called after throwing an error in the constructor";
- }
- else {
- cout << "Destructor was called";
- }
- }
- };
- int main() {
- file file1("asd");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment