随笔分类 -  C/C++

这是我的梦想
摘要:segment fault 段异常各种原因www.MyException.Cn 发布于:2012-11-26 11:48:50 浏览:24次 0segment fault 段错误各种原因一 造成segment fault,产生core dump的可能原因1.内存访问越界 a) 由于使用错误的... 阅读全文
posted @ 2014-06-04 18:12 Birding 阅读(1915) 评论(0) 推荐(0) 编辑
摘要:and运算通常用于二进制取位操作,例如一个数 and 1的结果就是取二进制的最末位。这可以用来判断一个整数的奇偶,二进制的最末位为0表示该数为偶数,最末位为1表示该数为奇数。or运算通常用于二进制特定位上的无条件赋值,例如一个数or 1的结果就是把二进制最末位强行变成1。如果需要把二进制最末位变成0... 阅读全文
posted @ 2014-05-18 17:44 Birding 阅读(309) 评论(0) 推荐(0) 编辑
摘要:一.内存对齐的初步讲解内存对齐可以用一句话来概括:“数据项只能存储在地址是数据项大小的整数倍的内存位置上”例如int类型占用4个字节,地址只能在0,4,8等位置上。例1:#include struct xx{ char b; int a; int c; char d;};int main(){ st... 阅读全文
posted @ 2014-05-02 16:49 Birding 阅读(298) 评论(0) 推荐(0) 编辑
摘要:1 #include 2 using namespace std; 3 struct struct1{ 4 /* 5 struct1(){ 6 cout<<"this is output by struct1 !"; 7 } 8 if add this code block , such errors like 'you must initlizer data number of struct1 9 10 by constructor in g++98' will occor in compile time,11 */12 ... 阅读全文
posted @ 2014-04-12 12:41 Birding 阅读(2670) 评论(0) 推荐(0) 编辑
摘要:#include using namespace std;class class1 { public: class1(){ } class1(int i ){ } void show(){ coutshow(); return 0;} 总结一下:1. 当使用类的无参构造函数来实例化对象时,... 阅读全文
posted @ 2014-04-12 12:40 Birding 阅读(528) 评论(0) 推荐(0) 编辑
摘要:1 #include 2 using namespace std; 3 struct struct1{ 4 int data1 ; 5 double data2 ; 6 struct1(){ 7 (*this).data1 = data1 ; 8 (*this).data2 = data2 ; 9 coutshowClass2();74 /* test struct inherit class */75 //struct4 onestruct4 ;76 //onestruct4.showCla... 阅读全文
posted @ 2014-04-11 23:53 Birding 阅读(981) 评论(1) 推荐(0) 编辑

点击右上角即可分享
微信分享提示