char* &CString转换问题
GetSectionValue(CString &strName);如果调用这样调用时候GetSectionValue("test");
报错:
错误 1 error C2664: 'CIniFile::GetSectionValue' : cannot convert parameter 1 from 'const char [5]' to 'CString &'
如果解决 vc --------------------编程问答-------------------- CString s="test";
GetSectionValue(&s); --------------------编程问答-------------------- 这样使用过,还是不行。。。。 --------------------编程问答-------------------- GetSectionValue(CString("test")); --------------------编程问答--------------------
你可能扫了一眼没注意上面的函数是用的引用。下面不能加取址符&。
用
CString s="test";
GetSectionValue(s);
应该是可以的吧 --------------------编程问答-------------------- 月经问题
CString s=_T("test");
GetSectionValue(&s); --------------------编程问答-------------------- CString s=L"test";
GetSectionValue(s);应该是可以的,原因是"test"是常量 --------------------编程问答-------------------- 因为函数定义的是引用,所以这边传递过去的应该是一个变量。使用GetSectionValue(CString("test"))是会OK的。 --------------------编程问答-------------------- CString s=L"test";
GetSectionValue(s);应该是可以的,原因是"test"是常量
学习了。。 --------------------编程问答-------------------- 百度一大把。
补充:.NET技术 , VC.NET