关于C++指针与结构体的使用问题及代码咨询
指针与结构体的实践代码
我最近一直在琢磨指针和结构体怎么配合使用,特意写了段代码来练手:
#include <iostream> using namespace std; struct Person { char name[20]; // *Question 2* int id; }; const int max_num_of_childs=10; struct Family { Person dad; Person mom; int num_of_childs; Person* child[max_num_of_childs]; }; void add_child (Family& f) { char answer; do { if (f.num_of_childs==max_num_of_childs) { cout << "no more children" <<endl; return; } cout << "more ...";
内容的提问来源于stack exchange,提问作者shir k
相关产品推荐
相关产品推荐

