cpp tutorial
minxuanjun
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
C++: 使用 Variadic template 实现任意个数的求最大值
#include <iostream> template <typename T> T my_max(const T &a, const T &b) { return a > b ? a : b; } template <typename T, typename... Args> T my_max(const T &a...原创 2018-09-30 14:13:13 · 629 阅读 · 0 评论 -
C++ 动态绑定和静态绑定
virtual 函数实现多态性 #include <iostream> using namespace std; struct TreeNode { TreeNode *left; TreeNode *rignt; }; class Generic_parser { public: void parse_preorder(TreeNode *node) ...翻译 2018-09-30 13:19:04 · 479 阅读 · 0 评论 -
c++ 计算一个数的正整数次幂,用到的知识点:模板特化,和递归。正整数次幂分为奇数和偶数次幂。
#include <iostream> #include <memory> #include <utility> template <int p> inline float specPow(float x) { if(p % 2 == 0) { float v = specPow<p/2>(x); ...原创 2019-01-29 09:25:45 · 681 阅读 · 0 评论
分享