随笔分类 -  C++

摘要:操作系统装载程序之后,首先运行的代码并不是main的第一行,而是某些别的代码,这些代码负责准备好main函数执行所需要的环境,并且负责调用main函数,这时候你才可以在main函数里放心大胆地写各种代码:申请内存、使用系统调用、触发异常、访问I/O。 一个典型的程序运行步骤大致如下: (1)操作系统 阅读全文

posted @ 2019-05-27 16:51 EMH1899

摘要:g++ -g -std=c++11 -m32 Test3.cpp -o Test3 注意这里是编的32位程序,如果编64位程序需要修改虚函数指针的偏移以及mem1和mem2的偏移 这是指向第一个虚函数的指针: (gdb) p /x *0xffffcaa0$5 = 0x8048b48 第一个虚函数的地 阅读全文

posted @ 2019-05-08 11:20 EMH1899 阅读(199) 评论(0) 推荐(0)

摘要:Exception Handling in C++ One of the advantages of C++ over C is Exception Handling. Exceptions are run-time anomalies or abnormal conditions that a p 阅读全文

posted @ 2019-05-07 15:42 EMH1899 阅读(181) 评论(0) 推荐(0)

摘要:12.5 — The virtual table 12.5 — The virtual table BY ALEX ON FEBRUARY 8TH, 2008 | LAST MODIFIED BY ALEX ON SEPTEMBER 24TH, 2018 To implement virtual f 阅读全文

posted @ 2019-05-06 14:37 EMH1899

摘要:Predict the output of following C++ program: Output: The above program calls only B’s constructor, it doesn’t call A’s constructor. The reason for thi 阅读全文

posted @ 2019-05-04 18:10 EMH1899

摘要:malloc() vs new Following are the differences between malloc() and operator new.: Calling Constructors: new calls constructors, while malloc() does no 阅读全文

posted @ 2019-05-04 09:31 EMH1899

摘要:References vs PointersBoth references and pointers can be used to change local variables of one function inside another function. Both of them can als 阅读全文

posted @ 2019-05-03 16:46 EMH1899

摘要:Can we make copy constructor private?Yes, a copy constructor can be made private. When we make a copy constructor private in a class, objects of that 阅读全文

posted @ 2019-05-03 16:15 EMH1899

摘要:内存管理是C++最令人切齿痛恨的问题,也是C++最有争议的问题,C++高手从中获得了更好的性能,更大的自由,C++菜鸟的收获则是一遍一遍的检查代码和对C++的痛恨,但内存管理在C++中无处不在,内存泄漏几乎在每个C++程序中都会发生,因此要想成为C++高手,内存管理一关是必须要过的,除非放弃C++, 阅读全文

posted @ 2019-05-02 17:18 EMH1899

摘要:1、继承和动态绑定对程序的编写有两方面的影响:一是我们可以更容易地定义与其他类相似但不完全相同的新类;二是在使用这些彼此相似的类编写程序时,我们可以在一定程度上忽略掉他们的区别。 2、在C++语言中,当我们使用基类的引用(或指针)调用一个虚函数时将发生动态绑定。基类通常都应该定义一个虚析构函数,即使 阅读全文

posted @ 2019-04-28 14:29 EMH1899

导航