Passing references to pointers in C++ -
As far as I can tell, there is no reason to allow me to pass the reference of an indicator in C ++ Should not be given. However, my efforts to do this are failing, and I do not know why
this is what I am doing:
zero myfunc (string * Amp; val) {// String Pointer} content / after some time {/ ... ... string s; Myfunc (& s); // ...} and I am getting this error:
changed parameter 1 from 'std :: string *' to 'std' Can not be done: String * & amp; '
Your function is expected to reference the actual string pointers in the calling area, one No Anonymous String Pointer Thus:
string s; String * _s = & amp; nbsp; Myfunc (_s); should be compiled properly.
However, this is only useful if you want to modify the pointer passing the function. If you intend to modify the string, then you should use the context of SAC in the context of SAC. With this, it should be more clear in the mind that the compiler complains about the original code about you, the pointer in your code has been created on 'fly', it is modified in that there will be no result of the pointer and this is not the same The purpose is. The idea of a reference (versus an indicator) is that a reference always indicates a real object.
Comments
Post a Comment