随笔分类 - C/C++
摘要:原文链接: https://blog.csdn.net/flowing_wind/article/details/81301001 参考资料:《C++ Primer中文版 第五版》 我们知道除了静态内存和栈内存外,每个程序还有一个内存池,这部分内存被称为自由空间或者堆。 程序用堆来存储动态分配的对象
阅读全文
摘要:General way to implement tcp servers is “one thread/process per connection”. But on high loads this approach can be not so efficient and we need to us
阅读全文
摘要:这样不行,没有成员函数的实现: #include <iostream> using namespace std; class Base1 { public: virtual void b1(); }; class Base2 { public: virtual void b2(); }; class
阅读全文
摘要:入门示例: 协程在单线程执行,foo1 执行完,才能执行 foo2: #include <iostream> #include <coroutine> #include <thread> #include <queue> #include <functional> std::queue<std::f
阅读全文
摘要:模板就是代码自动生成器,根据模板的规则自动生成类和函数。所谓的主模板和偏特化,都是代码生成的框架模型(类似面向对象的类和实现了部分功能的子类)。它们是抽象的存在,而不是具体的实例。只有全特化后,才是有了具体的实例,实实在在的存在(好比人(模板)和小明(实例)的关系)。 自己代码编写的全特化,就是自己
阅读全文
摘要:版权声明:本文为CSDN博主「爱码大鲤鱼」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。原文链接:https://blog.csdn.net/K346K346/article/details/81703914 1.简介子类为完成基类初始化,在 C++11 之前,需
阅读全文
摘要:#include <iostream> #include <map> using namespace std; int main() { map<int, string> m{{1, "one"}, {2, "two"},{3, "three"}, {4, "four"}, {5, "five"}}
阅读全文
摘要:1,下面编译运行没问题 #include <iostream> #include <unordered_map> #include <functional> using namespace std; void solve() { int x=100; typedef int (*MyType)(in
阅读全文
摘要:c++共享指针 shared_pointer
阅读全文
摘要:class A { public: void test() { std::cout << "test" << std::endl; } }; class B : public A { public: void test2() { std::cout << "test2" << std::endl;
阅读全文
摘要:返回多个值 C# 使用C# 7.0推出的值元组和解构功能。 static (int, int) Calc(int a, int b) { return (a + b, a - b); } static void Main() { var (add, sub) = Calc(8, 2); Consol
阅读全文
摘要:转自:C++11使用using定义别名(替代typedef) 大家都知道,在 C++ 中可以通过 typedef 重定义一个类型: typedef unsigned int uint_t; 被重定义的类型并不是一个新的类型,仅仅只是原有的类型取了一个新的名字。因此,下面这样将不是合法的函数重载: v
阅读全文
摘要:C++11: std::tuple | De C++ et alias OOPscenitates (oopscenities.net) 20150910OOPSCENE 从零开始的简单函数式C++(二)tuple - 知乎 (zhihu.com) 包装多个数据的元组 tuple 既然两个元素可以用
阅读全文
摘要:https://www.fluentcpp.com/posts/ 非常好的讲解c++ https://wandbox.org/permlink/P9OKYwkxGqMnTGT2 在线c++执行 本文转自:https://www.fluentcpp.com/2018/11/06/how-to-tran
阅读全文
摘要:// complex constructor example #include <iostream> // std::cout #include <complex> // std::complex using namespace std; using Complex = std::complex<d
阅读全文