一、结构体和类(class) 下面一个使用结构体类型的例子 类是面向对象语言的重要特征,下面是一个使用类的例子 c++里扩展了结构体的功能,使结构体也具有类的几乎所有特点,如可以包含成员函数,构造函数等等。类与结构体的区别在于:在默认状态下(即在不声明private和public时),结构的所有成员 ...
分类:
编程语言 时间:
2016-05-02 18:25:09
阅读次数:
239
#include"stdio.h"#include"conio.h"#definePAGE3#defineMAX1000#defineN5intk=0;/*结构体类型*/typedefstruct{intnum;/*宿舍号*/ intnumber;/*人数*/ charstudentclass[20];/*班级*/}STUDENTS;intread_file(STUDENTSstu[]){ FILE*fp;inti=0; if((fp=fopen("stu.txt","rt"))==N..
分类:
其他好文 时间:
2016-04-30 01:22:59
阅读次数:
170
#include"stdio.h"#include"stdlib.h"#include"string.h"#include"conio.h"#definePAGE3#defineMAX1000#defineN5intk=0;/*结构体类型*/typedefstruct{intnum;/*宿舍号*/charname[20];/*姓名*/ charsex[5];/*性别*/ intage;/*年龄*/ charstudentclass[20];/*班级*/ intscore;/*..
分类:
其他好文 时间:
2016-04-30 01:22:10
阅读次数:
217
#include"stdio.h"#include"stdlib.h"#include"string.h"#include"conio.h"#definePAGE3#defineMAX1000#defineN5intk=0;/*结构体类型*/typedefstruct{intnum;/*宿舍号*/charname[20];/*姓名*/charsex[5];/*性别*/intage;/*年龄*/charstudentclass[20];/*班级*/intscore;/*成绩*..
分类:
其他好文 时间:
2016-04-30 01:20:18
阅读次数:
240
内存分配
我们在前面的章节已经了解了值类型和引用类型,下面我们重点讲下值类型和引用类型在内存中的分配情况。
值类型实例通常分配在栈(Stack)上,并且不包含任何指向实例数据的地址,因为变量包含了其实例数据。值类型主要包括简单类型、结构体类型和枚举类型。
例如如下代码:int iCount=50; //声明和初始化变量iCount...
例14.2 对比向函数传递结构体数组名和向函数传递结构体变量名的区别。 输出结果: A)16, 90.0B)12, 77.5请按任意键继续. . . 例14.3 通过函数返回结构体类型的值。 输出结果: y.a=0,y.b=Ay.a=99,y.b=S请按任意键继续. . . 例14.4 通过函数的返 ...
分类:
编程语言 时间:
2016-04-27 06:52:57
阅读次数:
286
#include"stdio.h"#include"stdlib.h"#include"string.h"#include"conio.h"#definePAGE3#defineMAX1000#defineN5intk=0;/*结构体类型*/typedefstruct{intnum;/*编号*/charname[20];/*物品名称*/ charsex[5];/*种类*/ intage;/*保质期*/ charstudentclass[20];/*品牌*/ intscore..
分类:
其他好文 时间:
2016-04-26 22:24:01
阅读次数:
310
#include"stdio.h"#include"stdlib.h"#include"string.h"#include"conio.h"#definePAGE3#defineMAX1000#defineN5intk=0;/*结构体类型*/typedefstruct{intnum;/*学号*/charname[20];/*姓名*/ charsex[5];/*性别*/ intage;/*年龄*/ charstudentclass[20];/*班级*/ intscore;/*成..
分类:
其他好文 时间:
2016-04-26 22:24:01
阅读次数:
197
#include"stdio.h"#include"stdlib.h"#include"string.h"#include"conio.h"#definePAGE3#defineMAX1000#defineN5intk=0;/*结构体类型*/typedefstruct{intnum;/*学号*/charname[20];/*姓名*/charsex[5];/*性别*/intage;/*年龄*/charstudentclass[20];/*班级*/intscore;/*成绩*/}..
分类:
其他好文 时间:
2016-04-26 22:23:48
阅读次数:
369
#include"stdio.h"#include"stdlib.h"#include"string.h"#include"conio.h"#definePAGE3#defineMAX1000#defineN5intk=0;/*结构体类型*/typedefstruct{intnum;/*宿舍门牌号*/charname[20];/*姓名*/ charsex[5];/*性别*/ intage;/**/ charstudentclass[20];/*所属班级*/ intscore..
分类:
其他好文 时间:
2016-04-26 22:22:43
阅读次数:
237