#include<iostream>
//structure
struct CandyBar
{
char * name;
double weight;
unsigned hot;
};
//prototype
void setStruct(CandyBar & candy, char * pa = "Millennium Munch", double weight = 2.85, unsigned hot = 350);
void display(const CandyBar & dpCB);
//main
int main()
{
CandyBar CB;
setStruct(CB);
display(CB);
system("pause");
return 0;
}
//function
void setStruct(CandyBar & candy, char * pa, double weight , unsigned hot)
{
candy.name = pa;
candy.weight = weight;
candy.hot = hot;
}
void display(const CandyBar & dpCB)
{
using namespace std;
cout << "CandyBar name: " << dpCB.name << endl;
cout << "CandyBar weight: " << dpCB.weight << endl;
cout << "CandyBar hot: " << dpCB.hot << endl;
C++ Primer Plus 第六版 8.2 答案
最新推荐文章于 2021-06-13 22:19:35 发布