I've been trying to compile a program I've spent the past three days building, and I can't figure out how to get it to stop throwing an error. I keep getting the compile error "undefined reference to Foo::bar" where "bar" is a static ofstream declared in the Foo.h file.
Foo.h
Class Foo
{
public:
<insert methods>
private:
static ofstream& bar;
}
Foo.cpp
#include <iostream>
#include <fstream>
#include <sstream>
#include "EventReport.h"
using namespace std;
Foo::Foo()
{
bar.open("foobar.txt");
}
I keep getting the error message on the "bar" in Foo.cpp (there are multiple in the file). Any ideas on why?