2014年4月13日

typeid操作符

摘要: typeid() operator返回type_info,返回值不可拷贝、不可赋值// Illustrates the typeid operator.#include #include using namespace std;struct PolyBase { virtual ~PolyBase() {} };struct PolyDer : PolyBase { PolyDer() {} };struct NonPolyBase {};struct NonPolyDer : NonPolyBase { NonPolyDer(int) {} };int main() { // Test p. 阅读全文

posted @ 2014-04-13 15:51 FlowingCloud 阅读(286) 评论(0) 推荐(0) 编辑

函数对象

摘要: 函数对象是类似于函数的对象,就是具有operator()的对象#include #include using namespace std;void test(int i){ cout void myfor_each(Iter begin, Iter end, UnarFunc fun){ while (begin != end) { fun(*begin); //fun.operator()(*begin); ++begin; }}int main(int argc, char* argv[]){ int a[5] = {0,... 阅读全文

posted @ 2014-04-13 15:24 FlowingCloud 阅读(172) 评论(0) 推荐(0) 编辑

导航