怎样从vector中取出数据
数据库中有一个表usernamepasswordabc123456cbc369852publicclassInfo{privateStringusername;priva...
数据库中有一个表
username password
abc 123456
cbc 369852
public class Info{
private String username;
private String password;
//getter、setter
}
public class fromDb{
//省略其他
public Vector useinfo(){
Vector v=new Verctor
while(rs.next()){
Info.getUsername(rs.getString("username"));
Inor.getPassword(rs.getString("password"));
v.add(Info);
}
}
}
怎么从另一类,比如A类取出在Vector的值?谢谢! 展开
username password
abc 123456
cbc 369852
public class Info{
private String username;
private String password;
//getter、setter
}
public class fromDb{
//省略其他
public Vector useinfo(){
Vector v=new Verctor
while(rs.next()){
Info.getUsername(rs.getString("username"));
Inor.getPassword(rs.getString("password"));
v.add(Info);
}
}
}
怎么从另一类,比如A类取出在Vector的值?谢谢! 展开
2个回答
推荐于2018-03-07
展开全部
vector重载了[]操作符,所以取出数据和数组一样用;
参考方法如下:
vector<int> name1;
while(cin>>m_gname)
name.push_back(m_gname);
for(vector<string>::iterator iter1=name.begin();iter1!=name.end();iter1++)
{
cout<<*iter
}
参考方法如下:
vector<int> name1;
while(cin>>m_gname)
name.push_back(m_gname);
for(vector<string>::iterator iter1=name.begin();iter1!=name.end();iter1++)
{
cout<<*iter
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询