Passing an object to a function taking pointer as parameter
How does it work when I only have an object but my function takes 开发者_开发技巧a pointer to that type of object.
Someoclass test1;
SomeFunction( Someclass*)
{
//does something
};
You pass the address of the object.
SomeFunction(&test1);
To call the function, you need to use the address of operator (&). So in your case:
Someclass test1;
SomeFunction(&test1);
If you are asking how pointers work, there's a detailed explanation here.
精彩评论