J
Javi
Hi!. I'm trying to do something like this but results in lot of errors.
Can anybody tell me how to do it (first of all I hope you can grasp my
idea)?:
myfile.cpp
#include <iostream>
#include <fstream>
using namespace std;
class debuginformation{
public:
static fstream outfile;
static void message001(int n);
static void message002(double alpha);
};
fstream debuginformation:utfile("debug.dat"); //Is this rigth
// Maybe I should write fstream
debuginformation:utfile=fstream("debug.dat");?
void debuginformation::message001(int n){outfile<<"The var n
is"<<n<<endl;}
int main(){
// Do I have to declare any objects of class debuginformation?
// I only need to write the various static messages to the file
outfile.
int n=10;
debuginformation::message001(n);
}
If I compile this I get lot of errors complaining about:
undefined reference to `std::basic_ostream<char,
In methods involving this structure: outfile << anything.
Well I hope you can understand what I mean, maybe I've not been very
clear.
Thanks,
Javi.
Can anybody tell me how to do it (first of all I hope you can grasp my
idea)?:
myfile.cpp
#include <iostream>
#include <fstream>
using namespace std;
class debuginformation{
public:
static fstream outfile;
static void message001(int n);
static void message002(double alpha);
};
fstream debuginformation:utfile("debug.dat"); //Is this rigth
// Maybe I should write fstream
debuginformation:utfile=fstream("debug.dat");?
void debuginformation::message001(int n){outfile<<"The var n
is"<<n<<endl;}
int main(){
// Do I have to declare any objects of class debuginformation?
// I only need to write the various static messages to the file
outfile.
int n=10;
debuginformation::message001(n);
}
If I compile this I get lot of errors complaining about:
undefined reference to `std::basic_ostream<char,
std::char_traits said:(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
In methods involving this structure: outfile << anything.
Well I hope you can understand what I mean, maybe I've not been very
clear.
Thanks,
Javi.