c#轉c++ 與c++ list的問題
时间:2011-12-27
来源:互联网
C++ code:
//////GlobalCls.h裡的code://///
typedef struct struct_Lu
{
int a;
double x;
double y;
int z;
}Lu;
class GlobalCls
{
public:
list<Lu> listInfo;
};
////////////////////////////////
////////from1.h的code///////////
GlobalCls.listInfo.x;
錯誤:error C2039: 'x' : 不是 'std::list<_Ty>' 的成員
////////////////////////////////
1.請問要如何取出單一值,如取x或y.
2.假設存好了3筆list 又如何取其中一個list裡的x
請求各位高手解答,這已經讓我撞牆很久了!! 謝謝.
//////GlobalCls.h裡的code://///
typedef struct struct_Lu
{
int a;
double x;
double y;
int z;
}Lu;
class GlobalCls
{
public:
list<Lu> listInfo;
};
////////////////////////////////
////////from1.h的code///////////
GlobalCls.listInfo.x;
錯誤:error C2039: 'x' : 不是 'std::list<_Ty>' 的成員
////////////////////////////////
1.請問要如何取出單一值,如取x或y.
2.假設存好了3筆list 又如何取其中一個list裡的x
請求各位高手解答,這已經讓我撞牆很久了!! 謝謝.
作者: kranoawi 发布时间: 2011-12-27
Lu.x
作者: cbzjzsb123 发布时间: 2011-12-27
给你的程序参考,应该可以明白了
C/C++ code
C/C++ code
#include <iostream> #include <list> using namespace std; typedef struct struct_Lu { int a; double x; double y; int z; }Lu; class GlobalCls { public: list<Lu> listInfo; }; int main() { Lu lu; lu.a=10; lu.x=123.45; lu.y=456.78; lu.z=100; GlobalCls test; test.listInfo.push_back(lu); //添加一个数据 lu.a=2; lu.x=223.45; lu.y=256.78; lu.z=200; test.listInfo.push_back(lu); //添加第二个数据 list<Lu>::iterator plist; for(plist = test.listInfo.begin(); plist != test.listInfo.end(); plist++) //取出数据 cout << (*plist).a << " " <<(*plist).x <<endl; }
作者: keiy 发布时间: 2011-12-27
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28