== operator
From: sksjava (sksjava_at_hotmail.com)
Date: 01/19/04
- Next message: Aggro: "Re: Help on File Operations"
- Previous message: Martijn Lievaart: "Re: Changing a makefile from CC to gcc"
- Next in thread: Victor Bazarov: "Re: == operator"
- Reply: Victor Bazarov: "Re: == operator"
- Reply: Adam Fineman: "Re: == operator"
- Reply: sksjava: "Re: == operator"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 19 Jan 2004 09:16:13 -0600
I have overloaded the "==" operator for a class. But now I want to only
compare the addresses of the objects, is there is a c++ mechanism to do this
without casting?
Ex:- (not compileable)
void whatever(Something* one, Something* two) // "==" is overloaded for
class Something
{
// want to compare one's and two's addresses
if ( one == two ) {} // don't want to invoke the "==" operator
// only solution that I can think of
void* onev = reinterpret_cast<void*>(one);
void* twov = reinterpret_cast<void*>(two);
if ( onev == twov ) {}
}
- Next message: Aggro: "Re: Help on File Operations"
- Previous message: Martijn Lievaart: "Re: Changing a makefile from CC to gcc"
- Next in thread: Victor Bazarov: "Re: == operator"
- Reply: Victor Bazarov: "Re: == operator"
- Reply: Adam Fineman: "Re: == operator"
- Reply: sksjava: "Re: == operator"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]