I have limited experience with Object Oriented coding but not programming in general.
Here is a stripped down version of my code. What I'm trying to do is set a variable declared in 'CProjectView::Handler' using a function in 'CtestClass'. Simple enough! but not for me.
In the code as shown, testClass.cpp compiles with no errors, but projectView complains about a 'non-static' function. So I add 'static' to the function in testClass.h. Now testClass.cpp complains about a 'non-static' variable. So I add 'static' to the variable.
Bingo! Everything compiles without error.
BUT now when I try to 'link' this lot, I get an "unresolved external symbol...." error.
What am I doing wrong?
//// projectView.h
class CProjectView : public CView {
protected:
CProjectView();
public:
void Handler();
};
//// projectView.cpp
CProjectView::CProjectView() { // constructor
}
void CProjectView::Handler() {
int viewData; // trying to set this value.
if (CTestClass::aFunction(&viewdata)) {
...
} else { ... }
}
//// testClass.h
class CTestClass {
public:
CTestClass()
bool aFunction(int*);
private:
int varB;
};
//// testClass.cpp
CTestClass::CTestClass() { // constructor
varB = 555;
}
void CTestClass::aFunction(int *testdata) {
*testdata = anotherFunction(varB);
}