摘要: #include <iostream>using namespace std;int main(){ /* ** 脑海里要牢记:“*”是取地址内容的操作符,后面的值必须是个地址 ** int *p[2] ** 一维数组,数组大小为2,数组的元素是int的指针 ** 即数组中放的是int *的数据 */ int *p[2]; int a[3] = { 11, 21, 31 }; int b[4] = { 41, 51, 61, 71 }; //此时数组大小不限制 /* ** 注意不能使用p[2],否则数组越界 ** 如果... 阅读全文
posted @ 2012-05-22 21:26 木愚 阅读(245) 评论(0) 推荐(0) 编辑
摘要: #include <iostream>using namespace std;class A;class B{ friend A; // 友元类public: B( int b ) { this->b = b; }public: void funB( A * p );private: int b;};class A{public: A( int a ) { this->a = a; }public: friend void fun( const A & a ); // 友元函数 friend void B::funB( A ... 阅读全文
posted @ 2012-05-22 20:32 木愚 阅读(178) 评论(0) 推荐(0) 编辑
摘要: #include <iostream>using namespace std;class Time{public: int h; int m; int s; Time( int h = 0, int m = 0, int s = 0 ) { operator()(h,m,s); } //小括号重载 版本0 注意和下面用户自定义转换的区别 int operator()() { return h*3600 + m*60 + s; } //用户自定义转换 operator int() { ... 阅读全文
posted @ 2012-05-22 20:02 木愚 阅读(2176) 评论(0) 推荐(0) 编辑