首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

c++ 中vector如何输出 结构体数据

2013-01-21 
c++ 中vector怎么输出 结构体数据#include iostream#include vectorusing namespace stdtypedef stru

c++ 中vector怎么输出 结构体数据
#include <iostream>  
#include <vector>

using namespace std;

typedef struct
{
string str;
int inode;
}StrId; 

int main()
{
vector<StrId> t;
StrId str1;
str1.str = "This is a Test!";
str1.inode = 1;
t.push_back(str1);

for(vector<StrId>::iterator j=t.begin();j!=t.end();j++)
cout<< (*j).str<< " " << (*j).inode<<endl;

return 0;
}

D:\profile\CStud\CStud.cpp(1172) : error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' (or there is no acceptable conversio
这个程序cout<< (*j).str<< " " << (*j).inode<<endl;的这句话怎么写的 vector c++ struct
[解决办法]


cout<< (*j).str.c_str()<< " " << (*j).inode<<endl;

[解决办法]

// 或者包含 #include <string>

热点排行
Bad Request.