Hello,
Since a number of previous "How do I solve my globals?" topics, I've gone the OOP-ish way of programming. And I've ran into my first problem.
The problem instance data is saved into a class ("Instance"). It features a series of static member variables, such as instance size. Since this will stay the same throughout the runtime, I made it static. Also, it allowed me to easily access it from other classes that need the variable.
Now, after a bit of reorganizing, my Instance class has a member structure that provides an interface to a large (linearized) matrix. This requires one of the static variables. Since it is part of the Instance class, I thought this wouldn't be a problem, but it turns out it is:
1>Instance.obj : error LNK2001: unresolved external symbol "public: static unsigned int Instance::n" (?d@Instance@@2IA) |
Obvious solution? Remove the static and risk some insignificant memory waste of double parameters.
1>instance.h(37): error C2327: 'Instance::n' : is not a type name, static, or enumerator
1>instance.h(37): error C2065: 'n' : undeclared identifier |
The line in question looks like this:
inline unsigned operator()(const int &i, const int &j) const { return dists[i*n+j]; }
(In the static version, I replace 'n' with 'Instance::n').
The inclusion-order is pretty simple right now: Main includes one file, which includes Instance.h. Anyone who sees where the problem is?