Having some trouble understanding variable scope within a class structure.
I want to create a few variables in the class constructor and then have them available to the functions within that class. I thought that just defining them within the constructor would work, but my compiler (g++) gives me an error: 'foo' was not declared in this scope.
Can someone shed some light on this trivial problem?
Here is some dummy code to illustrate what I'm trying to do.
myClass.h
using namespace std;
class myClass{
public:
myClass(){
std::vector<int> foo;
foo.resize(10,0);
};
void myFunc();
}
myClass.cpp
void myClass::myFunc(){
std::cout << foo[1] << end;
// etc...
}