ahm*_*n86 0 c++ pointers function char parameter-passing
使用以下声明调用函数的最佳方法是什么?
string Extract(const char* pattern,const char* input);
Run Code Online (Sandbox Code Playgroud)
我用
string str=Extract("something","input text");
Run Code Online (Sandbox Code Playgroud)
这个用法有问题吗?
我应该使用以下内容吗?
char pattern[]="something";
char input[]="input";
//or use pointers with new operator and copy then free?
Run Code Online (Sandbox Code Playgroud)
两者都有效,但我喜欢第一个,但我想知道最佳实践.
| 归档时间: |
|
| 查看次数: |
5256 次 |
| 最近记录: |