//
// main.cpp
// structChapter
//
// Created by 炒饭 on 2019/4/14.
// Copyright © 2019 炒饭. All rights reserved.
//
#include <iostream>
//外部声明,可以被其他函数调用,放在main函数之前
struct inflatable
{
char name[20];
float volume;
double price;
};
//定义结构同时创建结构体变量
struct perks
{
int key_number;
char car[12];
} mr_smith , ms_jones;
struct perkss
{
int key_numer;
char cars[12];
} mr_glitez =
{
7,
"package"
};
int main()
{
// insert code here...
using namespace std;
inflatable guest =
{ //初始化成员用逗号隔开
"Glorious Gloria",
1.88,
29.99
};
inflatable pal
{
"Audacious Arthur",
3.12,
32.99
};
cout << "expand your guest list with "<< guest.name;
cout << " and "<< pal.name << "!\n";
cout << "You can have both for $";
cout << guest.price + pal.price <<"!\n";
//定义结构体数组
inflatable gifts[100];
cin >>gifts[0].volume;
inflatable guests[2]=
{
{"Bambi",0.4,21.22},
{"Godzilla",2000,456.22}
};
std::cout << "Hello, World!\n";
return 0;
}