2016年4月6日

C++中的友元和封装

摘要: 1 1 class A 2 2 { 3 3 int m_a; 4 4 public: 5 19 friend class B;//A为B的友元类 6 5 A::A(int a) :m_a(a) {} 7 6 void SetaValue(int a) 8 7 { 9 8 m_a = a; 10 9 ... 阅读全文

posted @ 2016-04-06 17:11 真.新手上路 阅读(237) 评论(0) 推荐(0)

2016年4月1日

Consistent::HashRing,一致性哈希。

摘要: 一致性哈希的实现理解 1 namespace 2 { 3 4 class StringifyException 5 { 6 }; 7 8 template 9 std::string Stringify(const T& t) 10 { 11 std::ostringstream os; ... 阅读全文

posted @ 2016-04-01 14:12 真.新手上路 阅读(422) 评论(0) 推荐(0)

2016年3月24日

C++中的lambda

摘要: lambda表达式:[](){} [capture list](argement list)mutable{function body} [capture list]: 1.[x] 值传递x 2.[&x]引用传递x 3.[=]值传递所有的lambda外的变量值 4.[&]引用传递所有的lambda外 阅读全文

posted @ 2016-03-24 16:08 真.新手上路 阅读(302) 评论(0) 推荐(0)

C++中的function

摘要: 学习C++中的function,记下,免得忘了。 更详细的可以看这里 阅读全文

posted @ 2016-03-24 14:12 真.新手上路 阅读(630) 评论(0) 推荐(0)

2016年3月18日

C++中的智能指针

摘要: 参考:http://www.cnblogs.com/lanxuezaipiao/p/4132096.html 1.auto_ptr:独占,但是如果赋值给别的指针的话,原先的就没了,并且没有提示。 结果如下: 所以上面的写法是非常容易出错误的,当引入新的指针进来的时候数组元素就丢失了所有权,推荐用sh 阅读全文

posted @ 2016-03-18 17:39 真.新手上路 阅读(185) 评论(0) 推荐(0)

导航