I'm writing a simple complex number C++ implementation as practice for overloading operator
s. One of the operators I simply cannot get past is <<
. I get an undefined reference error to it whenever I try to call it. Here is a gist link to my code. I am compiling it with the following:
g++ -std=c++11 main.cpp complex.cpp -Wall -Wextra -o complex
In addition to the unused parameter warning in main()
, I get the following:
/tmp/cc7qVwEF.o: In function `main':
main.cpp:(.text+0x1c5): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& rob::operator<< <char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, rob::Complex const&)'
collect2: error: ld returned 1 exit status