error C2228: left of '.year' must have class/struct/union type

来源:百度知道 编辑:UC知道 时间:2024/06/22 17:35:59
#include <iostream>
#include <string>
using namespace std;
int i=1;
struct Book{
char name;
int ID;
int price;
struct date;
}; Book b[20];
struct Date{
int year;
int month;
int day;
};

void add()
{

cout<<"输入书的名字,ID,价格,出版日期。\n";
cin>> b[i].name>> b[i].ID>> b[i].price>> b[i].date.year>> b[i].date.month>> b[i].date.day;
}
void putdown()
{int k,j;char name[20];
cout<<"输入书的名字\n";
cin>>name;
for(j=1;j<i;j++)
{if(strcmp(name,b[j].name)==0)
break;}

cout<<"把 "<<b[j].name<<" 从书篮中拿出";
for(k=j+1;k<i;k++){b[k-1]=b[k];}
i--;
}

void search_the_highest()
{
int max=0; int j;
for(j=1;j<=i;j++){if

//---------------------------------------------------------------------------
#include <iostream>
#include <string>
using namespace std;
int i=1;
struct Date{
int year;
int month;
int day;
};
struct Book{
char name[80]; /*注意这里*/
int ID;
int price;
struct Date date; /*注意这里*/
}; Book b[20];

void add()
{

cout<<"输入书的名字,ID,价格,出版日期。\n";
cin>> b[i].name>> b[i].ID>> b[i].price>> b[i].date.year>> b[i].date.month>> b[i].date.day;
}
void putdown()
{int k,j;char name[20];
cout<<"输入书的名字\n";
cin>>name;
for(j=1;j<i;j++)
{if(strcmp(name,b[j].name)==0)
break;}

cout<<"把 "<<b[j].name<<" 从书篮中拿出";
for(k=j+1;k<i;k++){b[k-1]=b[k];}
i--;
}