I have a problem with the compiler g ++ that shows me an error "po_bi was not declared in this scope" however when compiling with msvc compiles me without problem, how can I solve this error? The code consists of 3 parts: complex.h, complex.cpp and main.cpp.
complex.h
#if !defined(_COMPLEJO_H_)
#define _COMPLEJO_H_
class CComplejo {
friend CComplejo po_bi(const double mod, const double alfa);
private:
double real;
double imag;
public:
explicit CComplejo(const double r = 0, const double i = 0)
: real(r), imag(i) {}
};
#endif // _COMPLEJO_H_
complejo.cpp
#include <iostream>
#include <cmath>
#include "complejo.h"
CComplejo po_bi(const double mod, const double alfa)
{
return CComplejo(mod * cos(alfa), mod * sin(alfa));
}
main.cpp
#include <iostream>
#include "complejo.h"
int main()
{
CComplejo d;
double mod = 9.9;
double alfa = 4.5;
d = po_bi(mod, alfa);
}