Skip to content

Instantly share code, notes, and snippets.

View qiaohaijun's full-sized avatar
🎯
Focusing

qiao hai-jun qiaohaijun

🎯
Focusing
  • Beijing,China
View GitHub Profile
template <typename Type,
          typename Traits = DefaultSingletonTraits<Type>,
          typename DifferentiatingType = Type>
class Singleton {
 private:
  // Classes using the Singleton<T> pattern should declare a GetInstance()
  // method and call Singleton::get() from within that.
  friend Type* Type::GetInstance();

简介

  1. #include<sys/uio.h>
  2. iovec 表示i/o向量
  3. readv(2)和 writev(2)函数相关

结构体定义

#ifndef BASE_LOG_H_
#define BASE_LOG_H_
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <sys/time.h>
#ifdef DEBUG
#define CODE_INFO __FILE__, __PRETTY_FUNCTION__, __LINE__
  1. 这个和const一样,是对变量的限制 正如这个关键字的名字一样,这个关键字的意思就是,定义的变量是非常易变的。
C&C++——库头文件及其作用
1、 一些头文件的作用:
:ANSI C。提供断言,assert(表达式)
:GCC。GTK,GNOME的基础库,提供很多有用的函数,如有数据结构操作函数。使用glib只需要包含
:GCC。文件夹操作函数。struct dirent,struct DIR,opendir(),closedir(),readdir(),readdir64()等
:ANSI C。字符测试函数。isdigit(),islower()等
:ANSI C。查看错误代码errno是调试程序的一个重要方法。当linuc C api函数发生异常时,一般会将errno变量(需include errno.h)赋一个整数值,不同的值表示不同的含义,可以通过查看该值推测出错的原因。在实际编程中用这一招解决了不少原本看来莫名其妙的问题。比较麻烦的是每次都要去linux源代码里面查找错误代码的含义,现在把它贴出来,以后需要查时就来这里看了。来自linux 2.4.20-18的内核代码中的/usr/include/asm/errno.h
:处理命令行参数。getopt()

侯捷 Effictive C++ 的中文版

c++ 难在于提供了四种不同的程序设计思维模式

  1. procedural-based
  2. object-based
  3. object-oriented
  4. generics

pthread是历史悠久的多线程模型。

而且在三年前的时候,我还曾经说,c++太复杂了,我不要学习c++,没想到3年过去了,现在我反而要从头深入的学习一下c++。


c++的复杂

  1. c++ 模板编程

以前从学习c++的角度看问题,总是想着如何精通c++,其实这个角度有几个弊端

  1. c++ 太复杂

[MEC] 条款2 最好使用c++转型造作符.md

###基础内容

  1. 指针
  2. 引用
  3. 类型转换
  4. 数组
  5. 构造函数