知识库

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

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

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;
}
转载请注明转自www.hylab.cn,原文地址:C++语言开发示例:16. 结构体赋值

评论 (0)

登录后发表评论

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