How do you pass an unknown object into a function and save it? I'm trying to have a set and get function in a class I'm creating that can hold and return any object.
Here are my attempts so far:
void* holder;
void setHolder(void* object)
{
holder = object;
}
void* getHolder()
{
return holder;
}
OR
void setHolder(void* &object)
{
holder = object;
}
void* getHolder()
{
return holder;
}
I'm also unsure how I would enter the object into the function if one of these are correct.
ex.
Object object();
myClass.setHolder(&object); ?
or
Object* ptr = object;
myClass.setHolder(ptr); ?
Thanks for any help.