我有一个引用对象的函数:
void move(Ball& ball);
我有另一个调用“move()”的函数,它有一个指向球的指针:
void foo(Ball* ball){
//call move()
}
foo()
应该如何将球传给 move()
?
应该是这样的:
move(*ball);
或:
move(ball);
或:
move(&ball);
最佳答案
第一个,move(*ball)。
第二个,move(ball) 尝试传递指针,第三个,move(&ball) 尝试将指针传递给指针。
关于c++ - 我有一个指向对象的指针。如何调用需要引用的函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/552638/