积极答复者
这段代码不知道哪里错了

问题
-
答案
-
1 "SZ002325"是一个常量字符串,可以转成CString,但是s_compare的行参是CString*所以不行。该成
2 "SZ002325"是一个无名常量右值不能用来附值
麻烦把正确答案设为解答。- 已标记为答案 Honny_yeyh 2011年2月10日 9:17
-
Hi Honny_yeyh,
请你把代码按如下修改,您就可以把s_name和s_price的值传进去了。
class CComp { public: void s_compare(CString* s_name,int* price); int s_price; CString s_name; CComp(); virtual ~CComp(); }; void CComp::s_compare(CString* s_name, int* s_price) { CString na; s_name=&na; int nb; s_price=&nb; } CComp copp; CString* s=new CString(L"SZ002325"); int i=30; copp.s_compare(s,&i);
如果您的问题解决了,请把有用的回答标记为答案!
谢谢,
Lucy
Lucy Liu [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- 已标记为答案 Honny_yeyh 2011年2月10日 9:17
全部回复
-
1 "SZ002325"是一个常量字符串,可以转成CString,但是s_compare的行参是CString*所以不行。该成
2 "SZ002325"是一个无名常量右值不能用来附值
麻烦把正确答案设为解答。- 已标记为答案 Honny_yeyh 2011年2月10日 9:17
-
Hi Honny_yeyh,
请你把代码按如下修改,您就可以把s_name和s_price的值传进去了。
class CComp { public: void s_compare(CString* s_name,int* price); int s_price; CString s_name; CComp(); virtual ~CComp(); }; void CComp::s_compare(CString* s_name, int* s_price) { CString na; s_name=&na; int nb; s_price=&nb; } CComp copp; CString* s=new CString(L"SZ002325"); int i=30; copp.s_compare(s,&i);
如果您的问题解决了,请把有用的回答标记为答案!
谢谢,
Lucy
Lucy Liu [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- 已标记为答案 Honny_yeyh 2011年2月10日 9:17