
C++
Iceberg-X
Show me the code~
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
c++的友元类
#include //友元类using namespace std;class Rectangle;//长方形类的声明,因为在正方形类中,声明了一个长方形的友元类class Square//正方形的类{private: int side;//正方形的边长public: void setside(int a)//设置正方形的边长 { side=a; } friend cla原创 2013-12-14 21:07:49 · 850 阅读 · 0 评论 -
C++虚函数
/********************************************************************************* 如果想在基类中定义一个成员留待子类中进行细化,我们必须在它前面加关 键字virtual ,以便可以使用指针对指向相应的对象进行操作。************************************原创 2013-12-15 20:05:01 · 1650 阅读 · 0 评论 -
C++纯虚函数的this指针
#include using namespace std;class Test{protected: int height; int width;public: void setvalue(int a,int b) { width=a; height=b; } virtual int area()=0; void printarea() { coutarea(原创 2013-12-16 07:29:01 · 2274 阅读 · 0 评论 -
C++模版的使用
#include using namespace std;templateT getmax(T a,T b){ return(a>b?a:b);}void main(){ int a=5,b=6; float c=7.5,d=7.2; cout<<getmax(a,b)<<endl; cout<<getmax(c,d)<<endl; getchar();}原创 2013-12-16 07:38:27 · 1811 阅读 · 0 评论 -
C++基类的指针
#include //基类的指针using namespace std;class Test//父类{protected: int height; int width;public: void setvalue(int a,int b) { width=b; height=a; }};class Rectangle:public Test//子类{public:原创 2013-12-15 19:52:55 · 1735 阅读 · 0 评论 -
C++类的继承
#include using namespace std;class Test{protected: int height; int width;public: void setvalue(int a,int b) { height=b; width=a; }};class Rectangle:public Test{public: int area() {原创 2013-12-14 21:17:23 · 1246 阅读 · 0 评论 -
C++继承后的析构函数的调用
#include using namespace std;class Mother{public: Mother() { cout<<"mother:no parameters"<<endl; } Mother(int a) { cout<<"mother:int parameters"<<endl; }};class Daughter:public Mother{原创 2013-12-14 21:34:51 · 1720 阅读 · 0 评论 -
C++多重继承
#include using namespace std;class Test{protected: int height; int width;public: void setvalue(int a,int b) { height=a; width=b; }};class Cout{public: void output(int i);};void Co原创 2013-12-14 21:55:45 · 1618 阅读 · 0 评论 -
C++拷贝构造函数
#include //拷贝构造函数using namespace std;class CExample {private: int a;public: CExample(int b) //构造函数 { a = b; cout<<"creat: "<<a<<endl; } CExample(const CExample& C)//拷贝构造 { a = C.a;原创 2013-12-16 12:47:13 · 1825 阅读 · 0 评论