S
sksjava
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 ) {}
}
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 ) {}
}