Hello Sebastian!
You wrote:
SN> I have the following modules (files, they call 'em):
SN> CATALOG.CPP
SN> #include"fecha.hpp"
SN> FECHA.HPP
SN> struct fecha{
SN> int operator==(fecha& item);
SN> int operator>(fecha& item);
SN> int operator<(fecha& item);
SN> };
SN> .
SN> FECHA.CPP
SN> #include"fecha.hpp"
SN> int operator==(fecha& item){}
SN> int operator>(fecha& item){}
SN> int operator<(fecha& item){}
SN> When I compile everything in a single proyect ( ahm using
SN> Borland C++ 4.02)
SN> the linker tells that the operators in fecha are not definded in the
SN> module CATALOG.CPP. How come?
Because they aren't. You have declared three operators in the header as
member functions of the structure "fecha", so the code compiled in
CATALOG.CPP naturally looks for functions that are defined in that scope.
The three functions that you've defined in FECHA.CPP *are*not* members of the
structure! They are global functions. So the linker won't accept them as
the member functions that it is looking for.
Change the three function definitions in FECHA.CPP to
int fecha::operator==(fecha& item){}
int fecha::operator>(fecha& item){}
int fecha::operator<(fecha& item){}
and all will be well.
OBTW, your compiler should have issued an error (or at least a warning) when
you tried to compile FECHA.CPP, since the three global functions you'd
defined were never declared. This may be acceptable C, but it's a no-no in
C++.
-Ron (ron-bass@ti.com)
--- EZPoint V2.2
---------------
* Origin: There's a point here, somewhere... (1:128/13.3)
|