随笔分类 - C++
摘要:饿汉模式:上来不管三七二十一直接创建对象再说。 饿汉模式创建方式: 1.先创建一个私有的构造函数(防止其它地方直接实例化) 2.定义私有变量 3.提供公共的获取实例的方法 public class Single { //饿汉模式 //先创建一个表示单例的类 static class Singleto
阅读全文
摘要:#include <stdio.h> #define A(x, y)((x) * (y)) #define B(x, y)(x * y) void main() { //非表达式参数 printf("%d\n", A(11, 3)); //33 (11)*3 printf("%d\n", B(11,
阅读全文
摘要:tuple的应用场景: 1.多参和多返回值 #include <iostream> #include <tuple> using namespace std; tuple<string, int32_t, int64_t, float> f() { string s("string"); int32
阅读全文
摘要:#include <boost/asio/io_service.hpp> #include <boost/asio/write.hpp> #include <boost/asio/buffer.hpp> #include <boost/asio/ip/tcp.hpp> #include <array
阅读全文