知识库

C++语言开发示例:15. 结构体

2025-02-01 20:24:45 李腾 1 次阅读

structur.cpp

#include <iostream>

struct inflatable
{
    char name[20];
    float volume;
    double price;
};

int main()
{
    using namespace std;
    inflatable guest = {
        "Glorious Gloria",
        1.88,
        29.99};
    inflatable pal = {
        "Audancious 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";
}
转载请注明转自www.hylab.cn,原文地址:C++语言开发示例:15. 结构体

评论 (0)

登录后发表评论

暂无评论,快来发表第一条评论吧!