I wrote the following C++ program, but at the line where I used out_stream.open(), it keeps telling me that there are errors about “unknown typename ‘out_stream'” and “Expected unqualified-id”.
I am new to C++ and I think I just copied down the lines from my textbook, so I can’t figure out where it’s wrong. Please bear with me if it is a really simple mistake.
Here’s my code:
#include <iostream>
#include <fstream>
#include <cmath>
#include <vector>
#include <boost/random.hpp>
#include <boost/random/mersenne_twister.hpp>
#include <boost/random/normal_distribution.hpp>
#include <boost/random/uniform_int_distribution.hpp>
#include <boost/math/distributions.hpp>
std::ofstream out_stream;
out_stream.open("output.txt");
int main()
{
std::cout<<"hello world!";
return 0;
}
You cannot to this
outside of a function. Put it inside the main().