N
Nephi Immortal
I have two types – signed long and unsigned long. Are they really
signed int type? If unsigned long type is chosen, signed int is
chosen by C++ Compiler unless I declare explicit cast or error
ambiguous is reported.
void Do( signed int x ) {}
void Do( unsigned int x ) {}
int main()
{
signed long a = -1;
unsigned long b = 1u;
Do( a ); // OK
Do( b ); // error ambiguous
Do( static_cast< unsigned int >( b )); // OK
};
How can I use implicit cast and let C++ Compiler match signed int or
unsigned int?
signed int type? If unsigned long type is chosen, signed int is
chosen by C++ Compiler unless I declare explicit cast or error
ambiguous is reported.
void Do( signed int x ) {}
void Do( unsigned int x ) {}
int main()
{
signed long a = -1;
unsigned long b = 1u;
Do( a ); // OK
Do( b ); // error ambiguous
Do( static_cast< unsigned int >( b )); // OK
};
How can I use implicit cast and let C++ Compiler match signed int or
unsigned int?