Hi i'm new here and i'm really not familiar much with proper terminology since I originally studied C++ in Finnish.. So bear with me..
int Val (Var)
{
return int(Var);
}
how can I express Var so that it can be either a int value or a pointer to a int value?
Comments
{
return var;
}[/code]
Do you mean function overloading?
In that case, add this to Lundin's code:
[code]
int val (int* var)
{
return *var;
}
[/code]
Best Regards,
Richard
The way I see it... Well, it's all pretty blurry
union choose
{
int a;
int* b;
}Val;
int Var(union Val)
{ //do what you want to do with it}
However, this is still incomplete. There is no way to figure out whether the value in the union is a pointer or an integer value.
:
: Do you mean function overloading?
:
: In that case, add this to Lundin's code:
: [code]:
: int val (int* var)
: {
: return *var;
: }
: [/code]:
:
: Best Regards,
: Richard
:
: The way I see it... Well, it's all pretty blurry
Programming is a race between software engineers striving to build bigger and better idiot-proof programs,and the Universe trying to produce bigger and better idiots. So far,the Universe is winning.
: correctly. However, from what I have understood (of the question
: that is)
:
: union choose
: {
: int a;
: int* b;
: }Val;
:
: int Var(union Val)
: { //do what you want to do with it}
:
: However, this is still incomplete. There is no way to figure out
: whether the value in the union is a pointer or an integer value.
Hence, the C++ solution of function overloading: both an 'int' and an 'int*'.
Ofcourse, we're all still speculating until the OP says if we're on the right track or not.
Best Regards,
Richard
The way I see it... Well, it's all pretty blurry