C++语言开发示例:16. 结构体赋值
2024-07-11 10:45:28 2025-02-01 20:24:52 李腾 24 次阅读 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优化,请仔细甄别,转载请注明转自www.hylab.cn,原文地址:C++语言开发示例:16. 结构体赋值