Extend classes w/o inheritance?

Hello!

I'd like to implement operators > and < for bitset class. I know how to do this for a class of my own (1). I also know I could create a new class inheriting from bitset and implement those operators for it as in (1). The question is whether there is a way in C++ just to extend this base class, w/o creating an inherited child class on top of it?

Thanks!
You don't need to have operators overloaded as members of a class so you don't need a child class only for operator overloading

eg:
1
2
3
4
bool operator < ( const bitset & a, const bitset & b )
{
    //...
}
Wow, thanks for the quick reply! The declaration of the kind:

const bool operator >= (const bitset<REAL_FULL> &lhs, const bitset<REAL_FULL> &rhs);

seems to work well! The other (I use to define my class methods) didn't work though:

const bool operator >= (const bitset<REAL_FULL> &lhs, const bitset<REAL_FULL> &rhs) const;

Could you please tell me where I can look up the correct usage of the const keyword? Probably I just don't understand correctly what it's doing. So far I've read the great introductory tutorial on this site, but this does not seem to be covered there...?

Thanks!
the second declaration is a class member so you need only 1 argument as the other would be the class object ( this )

To see explanation/uses of 'const' try http://duramecho.com/ComputerInformation/WhyHowCppConst.html
Thank you very much, now it's clear! You're very helpful :)
Topic archived. No new replies allowed.