2016年11月17日

<C++>友元与虚函数的组合

摘要: 为类重载<<与>>这两个运算符时,重载函数必须为该类的友元函数。 当友元不能被继承,故不能当作虚函数,无法使用多态。 可以用以下结构实现友元与虚函数的组合。 1 class base { 2 public: 3 friend ostream & operator << (ostream &o, co 阅读全文

posted @ 2016-11-17 16:17 foundkey 阅读(934) 评论(0) 推荐(0) 编辑

导航