开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜