So I'm new to programming and I'm following a tutorial and I got to fstream, but I don't know if my compiler is acting weirdly or I'm missing a file or something but the .open function does not seem to work and fstream is acting weirdly. (Like you cannot use (ostreamobject)("test.txt"); I'm new to programming so please don't use technical terms.
I've searched around a bit but I didn't find anything.
I don't know what's wrong with my code or my compiler but outputFile.open does not exist weirdly enough. I'm using visual studio 2015. This is a small amount of code I wrote and it still comes with an error. Here's the code:
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
ostream oFile;
istream iFile;
oFile.open("test.txt");
return 0;
}
Here's the error codes:
1>d:\dokument\visual studio 2015\projects\fstream\fstream\fstream.cpp(13): error C2512: 'std::basic_ostream>': no appropriate default constructor available 1> d:\programmering\vc\include\iosfwd(679): note: see declaration of 'std::basic_ostream>' 1>d:\dokument\visual studio 2015\projects\fstream\fstream\fstream.cpp(14): error C2512: 'std::basic_istream>': no appropriate default constructor available 1> d:\programmering\vc\include\iosfwd(678): note: see declaration of 'std::basic_istream>' 1>d:\dokument\visual studio 2015\projects\fstream\fstream\fstream.cpp(16): error C2039: 'open': is not a member of 'std::basic_ostream>' 1> d:\programmering\vc\include\iosfwd(679): note: see declaration of 'std::basic_ostream>' ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========