如何从C++/CLI中的函数返回字符串?

问题描述:

我尝试以下如何从C++/CLI中的函数返回字符串?

String ^displayEmail(void){return (^Registration_List[0]);}; 

的VC++编译器2010显示如下:

Error 1 error C3192: syntax error : '^' is not a prefix operator (did you mean '*'?) c:\users\marco\desktop\cs351\hw3\project3\CRegistration.h 43 1 Project3 
Error 2 error C2440: 'return' : cannot convert from 'System::String' to 'System::String ^' c:\users\marco\desktop\cs351\hw3\project3\CRegistration.h 43 1 Project3 
+0

试着简单地删除^ s。从我可以看到他们是*(指针)的管理等价物,你可能不想返回。 – chris 2012-03-09 02:54:56

+0

在这个问题上使用C++标签只是搞乱了很多人,并且会让你得到很多不准确的答案。需要明确的是这是C++/CLI。 – 2012-03-09 03:03:35

+1

Registration_List的类型是什么?第一个^看起来好,但第二个不好。 – akhisp 2012-03-09 03:03:55

集市。 ^是按位“异或”运算符 定义中不能使用它

+0

它在Microsoft的C++ - CLI中有其他含义。 – 2012-03-09 03:00:00

+0

似乎就像那里叫[跟踪参考](http://*.com/questions/3380315/tracking-reference-in-c-cli)。 – 2012-03-09 03:03:23

Registration_List的类型是什么? 第一个^好像不错,但第二个不好。 - akhisp 12年3月9日3:03