I have a simple question that I haven't been able to find an answer to.
If I have a class with a constructor, for example,
class Test
{
public:
Test(int var);
~Test();
};
and I want to declare it outside of main, as a static global
For example.
static Test test1;
int main()
{
return 0;
}
I will get an error:
no matching function for call to 'Test::Test()'
If I try to use
static Test test1(50);
I will get errors: Undefined reference
What is the right way to do this? Do I need to have 2 constructors, one empty and 1 with variable?
Thanks,
Most likely you have to provide an implementation for your class constructors and destructor (even an empty implementation), e.g.: