You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

关于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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 07:08:31