Reputation: 63310
In C++, when you have a function that takes a reference to an object, how can you pass an object pointer to it?
As so:
Myobject * obj = new Myobject();
somefunc(obj); //-> Does not work?? Illegal cast??
somefunc(Myobject& b)
{
// Do something
}
Upvotes: 24
Views: 9500
Reputation: 504293
Just dereference the pointer, resulting in the lvalue:
somefun(*obj);
Upvotes: 30