摘要:
先看一段代码: template<typename T> void myfunc(T& tmprv) { cout << " begin " << endl; using boost::typeindex::type_id_with_cvr; cout << "T=" type_id_with_cv 阅读全文
posted @ 2024-03-30 22:01
小熊酱
阅读(43)
评论(0)
推荐(0)
摘要:
右值引用用&&符号表示。右值引用主要是绑定到右值上,如: int &&rv = 100; 看下面函数定义: void myfunc(int &&tmprv) { cout << tmprv << endl; return; } int main() { myfunc(10); // 正确,右值作为实 阅读全文
posted @ 2024-03-30 21:09
小熊酱
阅读(88)
评论(0)
推荐(0)
摘要:
先看一个多态的例子: class Human { public: virtual void eat = 0; virtual ~Human() {} }; class Men : public Human { public: virtual void eat() { cout << "男人" << 阅读全文
posted @ 2024-03-30 18:27
小熊酱
阅读(20)
评论(0)
推荐(0)
摘要:
1. 常规默认参数 类型模板参数可以有默认值。但指定默认值有一个规矩:如果某个模板参数有默认值,那么从这个默认值的模板参数开始,后面的模板参数都得有默认值。 template<typename T = char, typename U = int> struct TC { ... }; int ma 阅读全文
posted @ 2024-03-30 11:48
小熊酱
阅读(45)
评论(0)
推荐(0)

浙公网安备 33010602011771号