c++中List 如何使用

2024-11-24 05:55:24
推荐回答(4个)
回答1:

响应listbox的LBN_DBLCLK消息(就是双击消息)
在这个消息里面获取到选中的用户名
以这个用户名做索引,获取到此人的其他信息,比如(年龄,性别等)
然后定一个对话框,把这些值传入,再创建对话框即可:
CDlgInfo dlg;
dlg.username = "张三";
dlg.age = "33";
dlg.sex = "不男不女";
//必须把上面的值传给CDlgInfo上表示这些信息的响应控件的变量
dlg.DoModal();

回答2:

// list_begin.cpp
// compile with: /EHsc
#include
#include

int main( )
{
using namespace std;
list c1;
list ::iterator c1_Iter;
list ::const_iterator c1_cIter;

c1.push_back( 1 );
c1.push_back( 2 );

c1_Iter = c1.begin( );
cout << "The first element of c1 is " << *c1_Iter << endl;

*c1_Iter = 20;
c1_Iter = c1.begin( );
cout << "The first element of c1 is now " << *c1_Iter << endl;

// The following line would be an error because iterator is const
// *c1_cIter = 200;
}

回答3:

存储数据:
list l;
l.push_back(str);

取出:
list::const_iterator it;

for (it = l.begin(); it != l.end(); it++)
{
cout << *it << endl;
}

回答4:

list LoveSports;
LoveSports.push_back("篮球");
LoveSports.push_back("羽毛球");
LoveSports.push_back("排球");

list::iterator it = LoveSports.begin();

for (; it != LoveSports.end(); it++)
{
cout<<*it<}