F
foice
Hello to everybody. I read, and succesfully implented, some example of
use of a void* argument to pass a generic type argument to a function.
As far as I understand the trick is to recast the pointer to a pointer
of the correct type and then use this pointer as usual.
int f(void * input) {
float * x =(float*) input;
flaot value;
value=*x
cout<<value<<endl;
return 0
}
Now suppose that I want to compute something can I store this
"something" into a void* that is an argument of the function? I tried
this, but the value of the variable is not changed, as when I make a
cout it gives the same value of the initialization .
int f(void * argument) {
float result;
result=0;
argument=&result;
return 0
}
int main() {
float p;
p=11;
f( &p);
cout<<p<<endl;
return 0;
}
Any idea about what I am mistaking?
thanks a lot
Roberto
use of a void* argument to pass a generic type argument to a function.
As far as I understand the trick is to recast the pointer to a pointer
of the correct type and then use this pointer as usual.
int f(void * input) {
float * x =(float*) input;
flaot value;
value=*x
cout<<value<<endl;
return 0
}
Now suppose that I want to compute something can I store this
"something" into a void* that is an argument of the function? I tried
this, but the value of the variable is not changed, as when I make a
cout it gives the same value of the initialization .
int f(void * argument) {
float result;
result=0;
argument=&result;
return 0
}
int main() {
float p;
p=11;
f( &p);
cout<<p<<endl;
return 0;
}
Any idea about what I am mistaking?
thanks a lot
Roberto