摘要: 1. 函数可以通过重载进行灵活调用,但是通用性仍不够.此时模板显得更加强大. 如下面所示.//data.h进行声明#include "stdio.h"#include "iostream.h"#include <string>#if !defined(AFX_123)int add(int,int);template <class T1 t1,class T2 t2>double add(T1,T2);#define AFX_123#endif//data.cpp进行定义和调用#include "data.h" 阅读全文
posted @ 2013-01-10 12:44 血洗女生宿舍 阅读(130) 评论(0) 推荐(0) 编辑
摘要: 前面一节讲述的是类的单继承机制,本节重点讲述类的多继承问题.处理上述问题的方法是虚基类和虚继承. 具体如下-----------------------------------------------------------------class B:virtual public A{A1的定义形式};class B:virtual public A{A2的定义形式};则B是A的关系是虚继承关系, A是B的虚基类. 不能说A是虚基类,为什么?-----------------------------------------------------------------那么,通过上述定义后的, 阅读全文
posted @ 2013-01-05 15:09 血洗女生宿舍 阅读(376) 评论(0) 推荐(0) 编辑
摘要: 1. 最简单的多继承先对上面进行抽象#include "stdio.h"#include "iostream.h"#include <string>#if !define(AFX_123)class CAAA{private:int height;public:int GetHeight() const;CAAA(int);};class CBBB{private:char name;public:char GetName() const;CBBB();};class CSon{private:double classCdata;public 阅读全文
posted @ 2013-01-05 09:53 血洗女生宿舍 阅读(156) 评论(0) 推荐(0) 编辑
只有注册用户登录后才能阅读该文。 阅读全文
posted @ 2013-01-04 20:44 血洗女生宿舍 阅读(6) 评论(0) 推荐(0) 编辑
摘要: 主要讲述类的对象的构造过程,析构过程.1.data.h主要进行简单的声明#include "stdio.h"#include "iostream.h"#include <string>#if !defined(AFX_123)class CStudent{private:char* age;char* name;public:char* GetName() const;void SetName(char*);void display(void);CStudent(int,char*);CStudent(const CStudent&) 阅读全文
posted @ 2013-01-03 11:53 血洗女生宿舍 阅读(188) 评论(0) 推荐(0) 编辑
只有注册用户登录后才能阅读该文。 阅读全文
posted @ 2013-01-03 09:51 血洗女生宿舍 阅读(4) 评论(0) 推荐(0) 编辑
摘要: 有了基本数据类型之后,还不够用,这是需要对基本数据进行扩展,于是就有了数组和复合数据类型.1.先在h中定义数据//data.h文件#include "stdio.h"#include "iostream.h"#include <string>#if !defined(AFX_123)int apple[100];struct Student{int age;int height;int weight;};#define AFX_123#endif2. 在cpp中进行演示#include "data.h"void main( 阅读全文
posted @ 2013-01-03 07:50 血洗女生宿舍 阅读(127) 评论(0) 推荐(0) 编辑
摘要: 本文主要讲述C++基本数据类型,如何引用这些基本数据类型.1.在data.h中声明//data.h文件#include "stdio.h"#include <string>#in !undefined(AFX_123)int age;short height;long distance;float weight;double area;char c;char* p;char radio[10]={"hello C++"};bool result;#define AFX_123#endif2. 在data.cpp中定义和引用#include & 阅读全文
posted @ 2013-01-03 07:30 血洗女生宿舍 阅读(102) 评论(0) 推荐(0) 编辑