Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我被我的代码卡住了 20 分钟。
这个简单的 C 代码有什么问题?
void function (char & reference_to_something) {}
错误:
expected ';' , ',' or ')' before '&' token
C 没有引用;C++ 可以。
除了引用不允许更改其地址这一事实外,引用和指针之间没有语义差异。改用指针,你会没事的。
void function (char* pointer_to_something) {}
如果你想传递一个指针,你可以这样做:
void function (char * reference_to_something) { return; }