总所周知指针作为函数参数传递的时候 传递的是指针的拷贝(指针也是变量) 这里提供四种指针的传递方法 改到实际的指针。
#include#include #include using namespace std; void test1(char **string) { printf("string未操作之前的的指针%pn",string); *string = "hello world"; printf("string未操作之后的的指针%pn",string); } char *test(char *string) { string = "hello world"; return string; } void test2(char *&string) { string = "hello world"; } bool test3(shared_ptr &ptr) { if(ptr) return true; ptr=make_shared (10); return false; } int main3() { shared_ptr p; cout< char *str = NULL; test2(str); printf("str=%sn",str); getchar(); return 0; }



