标题:[求助]:如何用枚举形做数组下标
只看楼主
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



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-157599-1-1.html




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

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