- 博客(10)
- 收藏
- 关注
原创 组合
#include using namespace std; class eye { public: void look (void) { } //看 }; class nouse { public: void smell (void) { } //闻 }; class mouth { public: void eat (void ) { } //吃 }; class
2013-11-18 12:32:44
680
原创 虚基类派生的构造函数与析构函数
#include using namespace std; class A { private: int x; public: A ( int a = 0 ) { cout<<"A的构造函数被调用"<<endl; x = a; } ~A () { cout<<"A的析构函数被调用"<<endl; } }; class B :virtu
2013-11-02 20:26:45
805
原创 派生类的构造函数和析构函数
#include using namespace std; class B { private: int x; public: B ( int a = 0) { cout<<"B的构造函数被调用"<<endl; x = a; } ~B () { cout<<"B的析构函数被调用"<<endl; } void print() {
2013-11-01 20:31:16
617
原创 类的多基类继承
#include using namespace std; class A { private: int x; public: A ( int a = 0) { cout<<"A的构造函数被调用"<<endl; x = a; } void print() { cout<<x<<endl; } }; class B { public
2013-11-01 20:11:56
817
原创 explicit 显式转换 用法 没搞清楚了。
#include using namespace std; class test1 { private: int x; public: explicit test1 ( int num) { x = num; } void print() { cout<<x<<endl; } test1 operator << ( test1 p ); }; test1 test1
2013-10-09 19:53:38
1046
原创 explicit 用法,显式调用构造函数
explicit构造函数的作用 解析: explicit构造函数是用来防止隐式转换的。请看下面的代码: class Test1 { public: Test1(int n) { num = n; } //普通构造函数 private: int num; }; class Test2 { public: explicit Test2(int n) { num = n; } //explicit(显式
2013-10-09 17:17:11
917
原创 成员函数形式重载运算符 []
#include using namespace std; class demo { private: char * sz; int len; public: demo (int l = 0 ) // { len = l; sz = new char [len]; //分配内存 } ~demo() { delete [] sz;
2013-10-03 01:53:40
1251
原创 以成员函数形式 重载运算符
#include using namespace std; class point { private: float real, imag; public: point ( float a = 0, float b = 0) { real = a; imag = b; } void print () { cout<<real<<" "<<imag<<endl; }
2013-09-30 14:01:18
1900
原创 运算重载符学习
学习C++类对象 运算重载符 用来记录我学习的过程。。 #include using namespace std; class complex { private: double real, imag; public: complex ( double i = 0.0, double j =0.0) { real = i; imag = j; } complex ope
2013-09-30 04:24:25
629
原创 我的参考四班三倒
#include using namespace std; class work { private: // 年 月 日 bool Isyear ( int year ) //判断是否为 闰年 { return ( (0 == year % 4 && 0 != year % 400 ) || ( 0 == year % 400 )); } int GetmonthDay (
2013-09-30 03:57:52
1421
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅