RealityVelJackson
Programmer
What can one do if they need to pass an ADT to a function and all they have is a pointer to the ADT ? For example:
Code:
int main(){
MYTYPE* a = createInstance();
//Call func: doSomething( ??? )
/*
...with a as the argument.
In other words, dereference the pointer to somehow
expose the bare object *a in order to pass it
by-value. I'm not sure if i've ever seen
someone write doSomething(*a)...
*/
free(a);
return 0;
}
MYTYPE* createInstance(){
MYTYPE* p = malloc(sizeof(MYTYPE));
if(p == NULL) exit(1);
return p;
}
void doSomething(MYTYPE x){
...
}