- 博客(5)
- 收藏
- 关注
原创 Thinking in C++ 卷2中文版
让我们对bruceeckel的开源精神致以崇高的敬意IO流 You can do much more with the general I/O problem than just take standard I/O and turn it into a class。 如果你能产生通常看起来一样的容器——标准IO,文件,甚至内存块,以致于你只须仅仅记住一个接口,难道这不是很好的吗?这
2004-04-07 21:54:00
1703
原创 thinkng in c++卷2
向中间层造型正如你在前面使用Security类层次里所看到的,dynamic_cast能在一个有多个层的继承层次里探测到原来的类型和中间的类型。这儿是另一个例子://: C08:IntermediateCast.cpp#include #include using namespace std;class B1 {public: virtual ~B1() {}
2004-04-07 14:32:00
746
原创 thinking in c++卷2
多重继承RTTI必须与多重继承的所有复杂性正常工作,包括虚拟基类(在下一章深入讨论——你可以在阅读了第9章后回到这里)。//: C08:RTTIandMultipleInheritance.cpp#include #include using namespace std; class BB {public: virtual void f() {} vir
2004-04-07 14:31:00
939
原创 thinking in c++ 卷2
垃圾收集器为进一步阐述RTTI的特殊用法,下面的代码模拟了一个垃圾收集器。不同种类的“垃圾”被放入一个简单的容器,以后依据他们的动态类型排序。//: C08:Trash.h// Describing trash.#ifndef TRASH_H#define TRASH_H#include class Trash { float _weight;publi
2004-04-07 14:31:00
745
原创 thinking C++ 卷2
对大多数程序来说,向下造型不是必须的,因为在面向对象应用程序里多态每天都解决了大量的问题。可是,检查一个向更多派生类型造型的能力对大多实用程序如编译器,类浏览器和数据库都是很重要的。C++提供了dynamic_cast 操作符来检查造型。下面的程序是用dynamic_cast对上一个例子的重写://: C08:Security.h#ifndef SECURITY_H#define S
2004-04-06 15:22:00
760
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人