| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2069 人关注过本帖
标题:[求助]:如何用枚举形做数组下标
只看楼主 加入收藏
dafengxu
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2007-7-19
收藏
 问题点数:0 回复次数:0 
[求助]:如何用枚举形做数组下标
大家好,请问在VC2005下如何用枚举类型作数组下标啊?

部分原代码:
..............
public:
enum class TextBoxIndices
{
ACCOUNT,
FIRST,
LAST,
BALANCE
};

................
public: void SetTextBoxValues(array<String ^> ^values)
{
if (values->Length != TextBoxCount)
{
throw (gcnew ArgumentException(String::Concat(
L"There must be ", (TextBoxCount + 1).ToString(), L" strings in array")));
}
else
{
this->txb_Account->Text = values[TextBoxIndices::ACCOUNT];
this->txb_LastName->Text = values[TextBoxIndices::LAST];
this->txb_FirstName->Text = values[TextBoxIndices::FIRST];
this->txb_Balance->Text = values[TextBoxIndices::BALANCE];
}
}
编译出错,显示下标类型没有转换。
错误 1 error C2440: 'initializing' : cannot convert from 'BankLibrary::BankUIForm::TextBoxIndices' to 'int' i:\visual studio 2005\projects\banklibrary\banklibrary\BankUIForm.h 204
错误 2 error C3262: invalid array indexing: 0 dimension(s) specified for 1-dimensional 'cli::array<Type,dimension> ^' i:\visual studio 2005\projects\banklibrary\banklibrary\BankUIForm.h 204


搜索更多相关主题的帖子: 枚举 
2007-07-24 01:53
快速回复:[求助]:如何用枚举形做数组下标
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015240 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved