摘要: dynamic 转换时的类必须有虚函数,否则会编译报错。#include using namespace std;class A{public: int a ; int b; void prt(void){std::cout (pA); cout (rA); cou... 阅读全文
posted @ 2015-01-20 13:22 穆穆兔兔 阅读(1163) 评论(0) 推荐(0) 编辑
摘要: #include using namespace std;class A{public: int a ; int b; void prt(void){std::cout prt();}因为其为静态绑定,编译时就已经制定了函数的如可地址。输出结果为:> ./a.out prt her... 阅读全文
posted @ 2015-01-20 11:34 穆穆兔兔 阅读(252) 评论(0) 推荐(0) 编辑
摘要: #include struct CloneableBase { virtual CloneableBase* clone() const = 0;};templatestruct Cloneable : CloneableBase { virtual CloneableBase* clo... 阅读全文
posted @ 2015-01-20 11:15 穆穆兔兔 阅读(178) 评论(0) 推荐(0) 编辑
摘要: http://www.cnblogs.com/zhuyf87/archive/2013/03/12/2955058.html#includeusing namespace std;class CBird{public: CBird() { cout fly(); delete pBird... 阅读全文
posted @ 2015-01-20 10:26 穆穆兔兔 阅读(734) 评论(0) 推荐(0) 编辑