[英]the compiler doesn't recognize my struct members
我在开始时有以下代码:
#include<iostream>
using namespace std;
struct mehmandar{
char name[30];
char last_name[30];
long national_code;
long personal_code;
date birthday;
date employ_date;
mehmandar * nxt;
};
struct time{
int hour;
int min;
};
struct flight{
long flight_serial;
long plane_serial;
char from[30];
char to[30];
int traveller_num;
char pilot_name[30];
char pilot_lastnam[30];
mehmandar* mehmandar_majmue=NULL;
long total_price;
time flight_time;
flight * nxt;
};
int main() {
flight* temp=new flight;
cin >>temp->flight_time.hour;
return 0;
}
但是然后我得到一个错误,即结构飞行没有主体部分的成员flight_time并且时间没有在结构飞行部分中命名类型。
不要将time
用作全局类型。 它与同名的标准库函数冲突。
将其更改为my_time
或将其放在您自己的名称空间中。 例:
#include<iostream>
namespace MyApp
{
struct time
{
int hour;
int min;
};
struct flight
{
long flight_serial;
long plane_serial;
char from[30];
char to[30];
int traveller_num;
char pilot_name[30];
char pilot_lastnam[30];
long total_price;
time flight_time;
flight * nxt;
};
}
int main()
{
using namespace MyApp;
flight* temp=new flight;
std::cin >>temp->flight_time.hour;
return 0;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.