I’ve run into a problem where a field in my class is not accessible by the constructor in it’s .cpp file, for reasons unknown to me the .cpp doesn’t inherit it and I cannot construct it for use in the rest of my program
Here is the class containing the fields I wish to construct in Test.h
class Test
{
public:
Test();
virtual ~Test();
void count();
int counter();
};
And here is the constructor for the field ‘counter’ in Test.cpp
Test::Test() : counter(0){}
To my knowledge of C++ this should be correct as Test.cpp contains #include “Test.h” and the exact same code works when writing and construction classes when using just main.cpp and no headers, any ideas?
int counter();is a function declaration. remove the().