C++语言开发示例:16. 结构体赋值

2024-07-11 李腾 43 次阅读 0 次点赞

assign_st.cpp

#include <iostream>

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

int main()
{
    using namespace std;
    inflatable bouquet = {
        "sunflowers",
        0.20,
        12.49};
    inflatable choice;
    cout << "bouquet: " << bouquet.name << " for $";
    cout << bouquet.price << endl;

    choice = bouquet;
    cout << "choice: " << choice.name << " for $";
    cout << choice.price << endl;
}
本文由人工编写,AI优化,转载请注明原文地址: C++语言开发示例:16. 结构体赋值

评论 (0)

登录后发表评论

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