
C/C++
文章平均质量分 61
Firehotest
这个作者很懒,什么都没留下…
展开
-
C/C++: Inline function, calloc vs malloc
Inline function is like a macro definition. When it was be called in another function, the control right will not be changed to this function. The compiler will just replace the line of inline functio转载 2016-02-02 18:52:20 · 552 阅读 · 0 评论 -
C++: How is the process of function calling in C++
Following images are from http://www.xuebuyuan.com/528715.htmlIn general, the process of calling function is put the parameters into the stack, move the EBP and ESP (jump into another function),原创 2016-04-01 10:25:36 · 1079 阅读 · 0 评论 -
C++自学总结(持续更新ing)
C++的内存管理:与Java类似,C++把函数、局部变量放在栈空间,把对象放在了堆空间。当一个类为空类,但是创建了空类的对象,编译器同样会在堆空间分类内存。如果使用的Visual Studio的编译器,那么按照规定,每个类至少分配1Byte的空间。所以sizeof(一个空类的对象),将会得到结果1。注意sizeof求的是有多少个byte.如果在类当中包含了一个构造函数和析构原创 2016-03-26 22:49:41 · 569 阅读 · 0 评论 -
Self Summary: C++函数返回引用和指针的问题,局部对象与new对象的问题
C++的局部对象的概念:作用域在局部范围内(例如函数)的对象。这样的对象可以把对象的引用或者指针存在栈中,随着函数的结束而销毁,而把创建的对象内容存在堆中。如果需要在堆上创建对象,要么使用new运算符,要么使用malloc系列函数。而关键是理解好“自动存储”的概念[1]:Object obj;此时,obj是在栈上分配的吗?要回答这个问题,我们首先要理解这个语转载 2016-07-27 14:08:36 · 4847 阅读 · 0 评论 -
Notes: scanf dead lock problem and rand() in C
Scanf has a serious problem if you don't use it correctly. For example:int x,y;scanf("%d%d",&x,&y);If we input a charter instead of a number, system will continue using the last effectiv原创 2016-09-13 12:10:43 · 406 阅读 · 0 评论 -
C/C++ Notes: #define和#typedef的区别以及构造函数和析构函数
#define和#typedef的区别两者的最主要区别是前者是预编译阶段(没到编译阶段)进行的内容替换。而#typedef是在编译阶段为现有的类型(自定义或者基本类型)创建一个别名。前者在预编译阶段展开时,不会被检查语法,而后者会接受编译阶段的语法检查。举一个最经典的例子来说明这种字符串替换和定义一个新类型(类型别名)的区别:#define int_ptr in原创 2016-10-11 07:20:54 · 853 阅读 · 0 评论 -
C/C++ Programming Generals
Lower Language: Instructions that are directly tied to one machine.Middle level: C/ C++High level: MatlabBasic data types:int: - 2,147,483,648 till 2,147,483,647unsigned int: 0 till 4,29原创 2016-10-06 00:31:40 · 462 阅读 · 0 评论 -
C/C++ Notes: C++的*和&
关于*和&最容易混淆的是其在声明时和在变量名前的不同意思。总体而言,在声明时,*p 和 &var代表了p是指针,var是某个变量的引用。在其余情况,这些符号在变量名前的话,*代表取值而&代表取地址。原创 2016-10-05 23:09:17 · 449 阅读 · 0 评论 -
C++ Special: 四种类型转换
static_cast 、dynamic_cast、 reindivter_cast、 const_cast。四种类型转换。文章来自:http://www.cnblogs.com/TenosDoIt/p/3175217.html 和 http://blog.jobbole.com/108817/1、static_cast该运算符把exdivssion转换为typ转载 2017-08-10 03:24:42 · 649 阅读 · 0 评论