This is the mail archive of the libstdc++@sources.redhat.com mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: multiple definition of operator<< ?


On Sun, 10 Dec 2000, Thorsten Gecks wrote:

> ifndef KSIMONSTRUCTS_HH
> #define KSIMONSTRUCTS_HH
> 
> ostream & operator<<(ostream & os, const KSimoN::DocUnitPosition & pos)
> {
>   return os << '(' << pos.x << ',' << pos.y << ',' << pos.z << ')';
> }
> 
> #endif

You've defined this in a header file.  To prevent multiple instances 
of the function from conflicting, there are a few options.  You
can make it inline, make it static or you can guard it with an
#ifdef so that it will only appear in a single source file.

Or just move it to a source file and only place the declaration in the
header.  Personally, with these kinds of functions I either make them
inline or just put them in the right source file.

                                        -Dave

-- 

"Some little people have music in them, but Fats, he was all music,
 and you know how big he was."  --  James P. Johnson



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]