I wrote a testing class in a header like this:
File.h
#ifndef FILE_H
#define FILE_H
class File {
fstream stream;
public:
File(string path);
~File();
};
File::File(string path) {
stream.open(path);
}
File::~File() {
stream.close();
}
#endif // FILE_H
And in another file I included and used it like this:
t.cpp
#include <iostream>
#include <string>
#include <fstream>
#include "/home/unlimiter/Documents/programming/modules/cpp/uio/File.h"
using namespace std;
int main(int argc, char *argv[]) {
File f("/home/unlimiter/tst");
}
Why does errors occur (like that fstream is not defined) when I do that?
I tested writing the class inside 't.cpp' and that works fine