I'm trying to create a class of complex number and want to create the imaginary unit i as constant. I want to be able to use it in any code when the class is included. For example :
#include "complex.h"
complex c = 2*i;
I've tried to define it that way : static const complex i
in complex.h under public:
and const complex complex::i = complex(0,1)
in complex.cpp. But when I write the code on the top in main.cpp , I get undeclared variable error.
How can I do this?
Note : I've defined the =
and *
operators