摘要:
#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 ... 阅读全文
摘要:
#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() { ... 阅读全文