摘要: #include #include #include using namespace std;templateT mul(T a, P b) { return a * b;}templatestring mul(string a, int b) { string res; for ... 阅读全文
posted @ 2014-12-23 15:22 卖程序的小歪 阅读(135) 评论(0) 推荐(0) 编辑
摘要: 在C++模板中的类型参数一般可以使用typename和class,两者没有什么不同。但是typename比class多项功能:“任何时候当你想要在template中指涉一个嵌套从属类型名称,就必须在其前面加上关键字typename”因为C++默认情况下把属性都作为值来看待而不是类型。#include... 阅读全文
posted @ 2014-12-23 14:44 卖程序的小歪 阅读(211) 评论(0) 推荐(0) 编辑
摘要: #include #include using namespace std;class Base { public: int add(int a, int b) { return a + b; }};class Derived : public... 阅读全文
posted @ 2014-12-23 11:03 卖程序的小歪 阅读(100) 评论(0) 推荐(0) 编辑
摘要: #include #include using namespace std;int add(int a, int b) { return a + b;}int main() { function f = add; cout fsingle = bind(add, 1... 阅读全文
posted @ 2014-12-23 10:41 卖程序的小歪 阅读(123) 评论(0) 推荐(0) 编辑