随笔分类 -  C++

动态链接库和静态链接库
摘要:三篇介绍动态链接库和静态链接库的博文:http://blog.csdn.net/gamecreating/article/details/5504152http://blog.csdn.net/firefoxbug/article/details/7326465http://www.cnblogs.... 阅读全文

posted @ 2015-04-13 21:15 Ryan-Xing 阅读(127) 评论(0) 推荐(0)

C++动态内存管理之shared_ptr、unique_ptr
摘要:C++中的动态内存管理是通过new和delete两个操作符来完成的。new操作符,为对象分配内存并调用对象所属类的构造函数,返回一个指向该对象的指针。delete调用时,销毁对象,并释放对象所在的内存。但在程序中使用new和delete容易导致很多问题,这里列出三个比较容易犯的错误。我们new了一个... 阅读全文

posted @ 2015-04-10 12:30 Ryan-Xing 阅读(1035) 评论(0) 推荐(0)

Semaphore built from mutex in C++11
摘要:#include #include using namespace std;class semaphore{private: mutex mtx; condition_variable cv; int count;public: semaphore(int count_ = ... 阅读全文

posted @ 2015-03-04 12:46 Ryan-Xing 阅读(185) 评论(0) 推荐(0)

Visual Studio中的/MD, /MT, /MDd, /MTd 选项
摘要:Visual Studio中/MD, /MT, /MDd, /MTd表示多线程模块是否为dll。对于这几个选项我的理解如下:/MD: 定义了_MT和_DLL,让程序用多线程和dll版本的运行库。/MT: 让程序用多线程和静态版本的运行库。/MDd: 定义了_MT、_DLL、_DEBUG,让程序用de... 阅读全文

posted @ 2015-02-05 20:36 Ryan-Xing 阅读(802) 评论(0) 推荐(0)

Difference Between Vector and Deque in C++
摘要:1) Dequeue can quickly insert or delete both at the front or the end. However, vector can only quickly insert or delete at the end.2) Memory allocatio... 阅读全文

posted @ 2014-11-28 13:47 Ryan-Xing 阅读(128) 评论(0) 推荐(0)

Functions
摘要:1 Local static variablesLocal static variables are not destroyed when the function ends; they are destroyed when the program terminates.2. Function pa... 阅读全文

posted @ 2014-10-04 21:43 Ryan-Xing 阅读(228) 评论(0) 推荐(0)

Namespace, string, vector and array
摘要:1. Headers should not include using declarationCode inside headers ordinarily should not include using declarations. The reason is that the contents o... 阅读全文

posted @ 2014-10-03 16:52 Ryan-Xing 阅读(185) 评论(0) 推荐(0)

C++ Variables and Basic Types Notes
摘要:1. Type conversion:If we assign an out-of-range value to an object of unsigned type, the result is the remainder of the value modulo the number of val... 阅读全文

posted @ 2014-10-03 15:37 Ryan-Xing 阅读(184) 评论(0) 推荐(0)

abs(INT_MAX-(-1))
摘要:写一个程序,结果总是不对,check逻辑好几遍也没发现错误,无奈之下debug。发现一个有趣的现象abs(INT_MAX-(-1))返回值是-2147483648。于是看了下abs函数的代码实现。1 int __cdecl abs (2 int number3 )4 ... 阅读全文

posted @ 2014-08-15 17:03 Ryan-Xing 阅读(586) 评论(0) 推荐(0)

Relevance Between Variable Declaration and Definition in C++
摘要:A declaration makes a name known to a programm. A definition creates the assocatied entity. A variable declaration specifies the variable type and nam... 阅读全文

posted @ 2014-07-18 16:57 Ryan-Xing 阅读(235) 评论(0) 推荐(0)

Difference Between Initialization and Assignment in C++
摘要:Initialization happens when a variable is given a value at the moment it is created. Assignment obliterates the variable's current value and replace t... 阅读全文

posted @ 2014-07-18 15:56 Ryan-Xing 阅读(148) 评论(0) 推荐(0)