为了账号安全,请及时绑定邮箱和手机立即绑定

为什么编译的时候显示错误呢?: undeclared identifier?

为什么编译的时候显示错误呢?: undeclared identifier?

喵喔喔 2022-05-11 15:11:17
((CComboBox*)GetDlgItem(IDC_COMBO2))->AddString("1000以下");((CComboBox*)GetDlgItem(IDC_COMBO2))->AddString("1000元-2000元");((CComboBox*)GetDlgItem(IDC_COMBO2))->AddString("2000-3000");((CComboBox*)GetDlgItem(IDC_COMBO2))->AddString("3000以上");这段有问题吗?为什么编译的时候说错呢‘error C2065: 'IDC_COMBO2' : undeclared identifierF:\vc++程序\lesson8\Prop\Prop3.cpp(59) : error C2227: left of '->AddString' must point to class/struct/unionF:\vc++程序\lesson8\Prop\Prop3.cpp(60) : error C2227: left of '->AddString' must point to class/struct/unionF:\vc++程序\lesson8\Prop\Prop3.cpp(61) : error C2227: left of '->AddString' must point to class/struct/unionF:\vc++程序\lesson8\Prop\Prop3.cpp(62) : error C2227: left of '->AddString' must point to class/struct/unionError executing cl.exe.Prop.exe - 5 error(s), 0 warning(s)
查看完整描述

2 回答

?
慕容3067478

TA贡献1773条经验 获得超3个赞

IDC_COMBO2这个资源的ID你可能写错了,它不存在
GetDlgItem返回一个CWnd类,这是一个CComboBox的父类,再不能把他转为CComboBox类了,因为只可以子类转父类,不可以父类转子类

查看完整回答
反对 回复 2022-05-16
?
红颜莎娜

TA贡献1842条经验 获得超13个赞

说你的((CComboBox*)GetDlgItem(IDC_COMBO2))这部分需要是AddString所在的class/struct/union的对象指针;
申明如:
类名 *对象指针名
对象指针名 -> 成员名

查看完整回答
反对 回复 2022-05-16
  • 2 回答
  • 0 关注
  • 293 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号