c、c++ 结构体的嵌套


/************************************************************************/
/* 嵌套结构体
* C++
**/
/************************************************************************/ struct A
{
private:
int a1[20];
public:
void initialize();
struct B
{
private:
A *b;
int *p;
public:
void initialize(A *a);
void next();
int read;
void set(int i);
};
friend A::B;
}; void A::initialize()
{
memset(a1, 0, sizeof(a1));
}
void A::B::initialize(A *a)
{
b = a;
p = a->a1; } void A::B::set(int i)
{
*p = i;
}
/*
void main()
{
A a;
A::B b1,b2;
int i;
a.initialize();
b1.initialize(&a);
b2.initialize(&a); for (i =0; i<20; i++)
{
b1.set(i);
b2.set(i);
}
} /************************************************************************/
/* C
* 嵌套结构体
*
* */
/************************************************************************/ typedef struct A
{
int year;
int month;
int day;
}; typedef struct B
{
string name;
int age; union{
A aa;
}xy; struct A aa1;
}; void main()
{
B *b1 =NULL;
b1->xy.aa.day =1991;
b1->aa1.month = 7; getchar(); }

c、c++ 结构体的嵌套的更多相关文章

  1. (60) 结构体指针、结构体变量嵌套、结构体指针嵌套、函数指针、数组指针、指针数组、typedef 综合运用

    #include<stdio.h> #include<iostream> #include<malloc.h> /* author : 吴永聪 program: 结 ...

  2. C语言 结构体(嵌套结构体--结构体数组)

    //结构体--嵌套结构体和结构体数组 #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <stdlib.h> ...

  3. golang中结构体的嵌套、方法的继承、方法的重写

    package main import "fmt" type human struct { name, phone string age int8 } type student s ...

  4. C++结构体与Delphi结构体相互传参,结构体中包含结构体的嵌套,数组指针

    //结构体的声明 typedef struct Mwinddirectbaseline { char* p; int s; int i; }Mwinddirectbaseline; typedef s ...

  5. HDU-1495 非常可乐 (嵌套结构体-广搜 对比 一般广搜)

    题意 大家一定觉的运动以后喝可乐是一件很惬意的事情,但是seeyou却不这么认为.因为每次当seeyou买了可乐以后,阿牛就要求和seeyou一起分享这一瓶可乐,而且一定要喝的和seeyou一样多.但 ...

  6. abap中结构体嵌套结构体。

    1: 结构体中嵌套结构体. *&---------------------------------------------------------------------* *& Re ...

  7. jchdl - RTL实例 - And2And(结构体嵌套的使用)

    https://mp.weixin.qq.com/s/PQIPkDymvcGc_re8ux50vA   结构体可以嵌套使用.   参考链接 https://github.com/wjcdx/jchdl ...

  8. C语言回顾-结构体、枚举和文件

    1.构造类型 根据已经定义的一个或多个数据类型用构造的方法来定义. 分为:数组.结构体和共用体 2.结构体 struct 结构体名{ 成员列表: }; 1)结构体定义完成以后,计算机不会给结构体分配存 ...

  9. 瘋子C语言笔记(结构体/共用体/枚举篇)

    (一)结构体类型 1.简介: 例: struct date { int month; int day; int year; }; struct student { int num; char name ...

随机推荐

  1. Python学习笔记(3)--数据结构之列表list

    Python的数据结构有三种:列表.元组和字典 列表(list) 定义:list是处理一组有序项目的数据结构,是可变的数据结构. 初始化:[], [1, 3, 7], ['a', 'c'], [1, ...

  2. 使用maven安装jar到本地仓库

    mvn install:install-file "-DgroupId={安装的jar包的groupid,可以随意起名}" "-DartifactId={安装jar包的I ...

  3. STM32中断名词

    1.NVIC的优先级概念    占先式优先级 (pre-emption priority):    高占先式优先级的中断事件会打断当前的主程序/中断程序运行— —抢断式优先响应,俗称中断嵌套.    ...

  4. ImageLoader的简单分析(二)

    在<ImageLoader的简单分析>这篇博客中对IImageLoader三大组件的创建过程以及三者之间的关系做了说明.同一时候文章的最后也简单的说明了一下ImageLoader是怎么通过 ...

  5. 阿里云aliyunlive视频直播,设置元素浮在视频上方

    视频直播,视频是可以看到了.但是还需要其他的元素,比如聊天内容,小礼物效果,观看人员列表等等.怎样让其他的元素,浮在视频上方呢? 解决方案,通过打开一个frame层,设置body的背景为透明的. 新的 ...

  6. CentOS7 启动[root@localhost ~]# systemctl start docker Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for de

    1).在linux虚拟机上安装docker步骤:1.检查内核版本,必须是3.10及以上uname ‐r2.安装dockeryum install docker3.输入y确认安装4.启动docker[r ...

  7. Bundle捆绑压缩技术

    Bundle捆绑压缩技术由命名空间System.Web.Optimization中的类提供.顾名思义,这些类是用来优化Web页面性能的,它们通过压缩文件大小,捆绑文件(把多个文件合成一个下载文件)来实 ...

  8. Centos7最小化安装后再安装图形界面

    1. yum -y groupinstall "X Window System" 2. yum -y groupinstall "GNOME Desktop"  ...

  9. pwd---以绝对路径的方式显示用户当前工作目录

    pwd命令以绝对路径的方式显示用户当前工作目录.命令将当前目录的全路径名称(从根目录)写入标准输出.全部目录使用/分隔.第一个/表示根目录,最后一个目录是当前目录.执行pwd命令可立刻得知您目前所在的 ...

  10. selenium使用报错“selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.”

    安装了python3,使用pip安装了selenium,但是在使用时,报了“selenium.common.exceptions.WebDriverException: Message: 'gecko ...