结构成员的读取问题
帮忙看下我的程序哪有问题:#include <iostream>
#include <string>
int main()
{
using namespace std;
struct car
{
string mader;
int year;
};
car *ps=new car;
int number;
cout<<"How many cars do you wish to catalog:";
cin>>number;
for(int i=0;i<number;i++)
{
cout<<"\nCar #"<<i<<":"<<endl;
cout<<"Please enter the make:";
cin.get(*(ps+i).mader);
cout<<"please enter the year made:";
cin>>*(ps+i).year;
}
cout<<"Here is your collection:"<<endl;
for(int i=0;i<number;i++)
cout<<*(p+i).year cout<< *(p+i).mader<<endl;
}
编译出现:
error C2228: left of '.mader' must have class/struct/union type
error C2228: left of '.year' must have class/struct/union type