07 2016 档案

摘要:一般来说,对于重载函数来说,由于顶层const不影响传入函数的对象,所有两个函数只是顶层const的区别的话,两个函数是等价的,定义为重载函数是非法的。 但是,另一方面,对于指针和引用来说,可以通过区分形参指向的是常量还是非常量来实现函数重载。此时的const是底层的。 Example: Recor 阅读全文
posted @ 2016-07-23 07:49 Vzf 阅读(470) 评论(0) 推荐(0)
摘要:#include #include int sum(std::initializer_list il) { int sum = 0; for (auto i : il) sum += i; return sum; } int main(void) { std::cout << sum({1, 2, 3, 4, 5}) << std::endl; re... 阅读全文
posted @ 2016-07-22 10:37 Vzf 阅读(504) 评论(0) 推荐(0)