
C++
熟练工
这个作者很懒,什么都没留下…
展开
-
类图关系-重温基础
泛化=实现>组合>聚合>关联>依赖原创 2021-11-23 11:56:06 · 357 阅读 · 0 评论 -
C++特性之tuple/bitset
tuple是一个超级pair类型的模版,pair类型智能有两个成员,但是tuple能够有任意数量的成员例子:#include <iostream> #include <tuple>using namespace std;int main(void) { tuple<int ,int ,double> tp(1, 2, 1.2); cout << "the first data is " << get<原创 2021-11-09 21:48:45 · 599 阅读 · 0 评论 -
C++特性之智能指针(shared_ptr,auto_ptr)
这位仁兄写的挺好,附链接:1. shared_ptr是Boost库所提供的一个智能指针的实现,shared_ptr就是为了解决auto_ptr在对象所有权上的局限性(auto_ptr是独占的),在使用引用计数的机制上提供了可以共享所有权的智能指针.2. shared_ptr比auto_ptr更安全3. shared_ptr是可以拷贝和赋值的,拷贝行为也是等价的,并且可以被比较,这意味这它可被放入标准库的一般容器(vector,list)和关联容器中(map)。智能指针(auto_ptr原创 2021-11-02 16:26:29 · 237 阅读 · 0 评论 -
C++特性之强制类型转换
static_cast <类型说明符> (表达式) 用于一般表达式的类型转换 int a ; double d= 3.1415; a = static_cast<int> (d);reinterpret_cast <类型说明符> (表达式) 用于非标准的指针数据类型转换,例如将void*转换为char*const_cast <类型说明符> (表达式)将const表达式转换为非常量类型,常用于将cons...原创 2021-11-02 10:36:41 · 97 阅读 · 0 评论 -
C++特性之using
引用命名空间using namespace std;重载父类函数 引用基类成员名称class Base {public : u_int8 base_func{ return size; };protect: u_int8 size;}class Sub : private Base {public : using Base::base_func(); using Base::size;}int main() { ...原创 2021-11-02 09:22:14 · 250 阅读 · 0 评论 -
C++特性之左值引用,右值引用
test原创 2021-11-01 16:48:54 · 79 阅读 · 0 评论 -
C++特性之std::thread
Example :auto function = [] { std::cout << " hello world " << std::endl;}std::thread thread1(function); if(thread1.joinable()) { thread1.join();}thread1.get_id();std::thread::hardware_concurrency() << std::endl; s...原创 2021-10-29 14:50:46 · 111 阅读 · 0 评论 -
C++特性之auto/decltype,返回类型后置
auto推导变量类型auto i= 10;decltype推导表达式类型int func() {return 0;}decltype(func()) c; //c为int返回类型后置传统定义方式 int ret(int a, int b);C++11之后 auto ret(int a, int b)->int;原创 2021-10-29 09:37:15 · 174 阅读 · 0 评论 -
C++特性之lambda
C++11新增特性std::function, std:bind, lambda表达式原创 2021-10-02 15:27:12 · 108 阅读 · 0 评论