#include <iostream>
struct inflatable //struck defination
{
char name[20];
float volume;
double price;
};
int main()
{
using namespace std;
inflatable* ps= new inflatable;//为结构体分配内存空间
cout<<"Enter name of inflatable item: ";
cin.get(ps->name,20);//method 1 for member access
cout<<"Enter volume in cubic feet: ";
cin>>(*ps).volume;//method 2 for member acess
cout<<"Enter price: $";
cin>>ps->price;
cout<<"Name: "<<(*ps).name<<endl;//method 2
cout<<"Volume: "<<ps->volume<<" cubic feet\n";//method 1
cout<<"Price: $"<<ps->price<<endl;//method 2
//如果结构标识符是结构名,则使用句点运算符;如果标识符是指向结构的指针,则使用箭头运算符
delete ps;
return 0;
}