I am helping a friend with his code to make a complex number class, which also stores the display type. Here is a simplified version of it:
enum class DisplayType
{
RECTANGULAR_FORM,
POLAR_FORM
};
class Complex
{
private:
float real, imaginary;
static DisplayType displayType;
public:
static DisplayType getDisplayType()
{
return Complex::displayType;
}
static void setDisplayType(DisplayType dp)
{
displayType = dp;
}
}
int main()
{
Complex::setDisplayType (DisplayType : :RECTANGULAR_FORM);
}
We keep getting the error “LNK2001 unresolved external symbol’private:static enum DisplayType Complex::displayType’”. DisplayType needs to be static in the Complex class(as per the requirements of our teacher).
What are we doing wrong?
We tried looking the error up, but we didn’t get anything concrete. We also tried not using static for displayType in the complex class (and subsequently not using static for the methods either). That compiled, but displayType needs to be static…