K
kalki70
Hello,
If I have a function like :
long long getNumber();
I can use implicit casting, so I can use this function with any
compatible value, for instance:
int a = getNumber();
unsigned short b = getNumber();
long c = getNumber();
....etc...
But what happens if the method is like : ?
void getNumber(long long &number);
Now I can't do this:
int a;
getNumber(a);}
I can't even do this :
unsigned long long a;
getNumber(a);
Is there a way to do it? I know where a reference is used actually the
pointer is passed, so I see the problem in the size of the different
variables.
What bothers me is that using the second approach I would have to
define all possible values :
void getNumber(char &number);
void getNumber(short& number);
void getNumber(int& number);
void getNumber(long& number);
void getNumber(long long& number);
and also the combinations with "unsigned".
Thanks for any advice,
Luis
If I have a function like :
long long getNumber();
I can use implicit casting, so I can use this function with any
compatible value, for instance:
int a = getNumber();
unsigned short b = getNumber();
long c = getNumber();
....etc...
But what happens if the method is like : ?
void getNumber(long long &number);
Now I can't do this:
int a;
getNumber(a);}
I can't even do this :
unsigned long long a;
getNumber(a);
Is there a way to do it? I know where a reference is used actually the
pointer is passed, so I see the problem in the size of the different
variables.
What bothers me is that using the second approach I would have to
define all possible values :
void getNumber(char &number);
void getNumber(short& number);
void getNumber(int& number);
void getNumber(long& number);
void getNumber(long long& number);
and also the combinations with "unsigned".
Thanks for any advice,
Luis