摘要: 以一个学生信息的结构体数组为例。 #include<iostream>#include<string>#include<fstream>using namespace std;struct Student{public: int n;//学号 char name[20];//姓名 int age;/ 阅读全文
posted @ 2016-07-21 11:07 Anna-SZ 阅读(2085) 评论(0) 推荐(0)
摘要: 两种方式。 一,二级指针,创建2行3列的动态二维数组。 这里,p指向的是2个地址,这两个地址各指向长度为3的一维整型数组。 在内存中,每行元素内部顺序排列。两行元素的首地址不同,p[1]与p[2]存放于不同空间。 int **p=new int*[2]; for(int i=0;i<2;i++){ 阅读全文
posted @ 2016-07-21 09:57 Anna-SZ 阅读(587) 评论(0) 推荐(0)

摘要: 文章引用自:http://blog.163.com/clevertanglei900@126/blog/static/111352259201102441934870/ 重载overload:是函数名相同,参数列表不同 重载只是在类的内部存在。但是不能靠返回类型来判断。 重写override:也叫做 阅读全文
posted @ 2016-07-20 09:32 Anna-SZ 阅读(258) 评论(0) 推荐(0)

摘要: 虚函数引入原因:为了方便使用多态特性,我们常常需要在基类中定义虚函数,在子类中重写虚函数。 class Cman { public: virtual void Eat(){……} void Move(); private: }; class CChild : public CMan { public 阅读全文
posted @ 2016-07-13 20:16 Anna-SZ 阅读(216) 评论(2) 推荐(0)

2016年7月18日

摘要: 类的成员引用有两种方法:继承和友元函数。 阅读全文
posted @ 2016-07-18 15:14 Anna-SZ 阅读(87) 评论(0) 推荐(0)

2016年7月14日

摘要: void writefile(student *s,int n,string filepath){ ofstream myfile; if(!myfile)//有错误 { exit(1); }else//文件存在 ,可以在文件末尾写入 { myfile.open(filepath); for(int 阅读全文
posted @ 2016-07-14 15:33 Anna-SZ 阅读(352) 评论(0) 推荐(0)
摘要: void readfile(string filepath){ ifstream myfile; if (!myfile) { cout << "打开文件出错!"; exit(1); }else{ myfile.open(filepath); string ss; while(getline(myf 阅读全文
posted @ 2016-07-14 11:37 Anna-SZ 阅读(170) 评论(0) 推荐(0)

导航