When I try to compile this code
Analysis2::Analysis2() //line 13
{
Seconds_v = 0; //Seconds_v and Seconds_t are both of type int
Seconds_t = 0; //and declared in header
}
I get this error
analysis2.cpp:13: undefined reference to `FileParameters::FileParameters()’
Why is it giving me that undefined reference? FileParameters is a class included in Analysis2 and there is a FileParameters object defined in the Analysis2 header file if that helps.
When you have constructor, every member variable is automatically default-constructed if you don’t explicitly construct it in the initializer list. Your code above automatically expands to:
And if you didn’t implement the default constructor of
FileParametersyet, or don’t even have an accessible one, that’s the error you get.