C++内存管理
princeteng
这个作者很懒,什么都没留下…
展开
-
C++菱形继承问题
1. 什么是菱形继承基类A,B继承A,C继承A,D继承BC。D中的B对象有A,D中的C对象还有A,重复了,如果调用函数,则不知道是B中的函数还是C中的函数。#include <iostream>using namespace std;class A {public: A() { a = 1; } ~A() {} void fun() { cout << ...原创 2020-04-04 22:38:05 · 244 阅读 · 0 评论 -
gnu c++的allocator
1.gnu c++中的allocator类型array_allocatorbitmap_allocator(和mfc中的bitmap无关)malloc_allocatormt_allocator(多线程)new_allocatorextptr_allocatordebug_allocatorpool_allocatorthrow_allocator其中new_allocato...原创 2019-12-05 21:14:46 · 405 阅读 · 0 评论 -
new_handler/set_new_handler/get_new_handler
1.new_handlernew_handler是在new失败后的处理方式,该处理方式由程序员自定义。new_handler是一个函数指针:typedef void (*new_handler)();.通过set_new_handler可以设置在new失败后调用哪个new_handler。2.set_new_handlerset_new_handler用来设置当动态内存分配失败时使用哪...原创 2019-12-04 11:18:42 · 218 阅读 · 0 评论 -
new/delete/array new/array delete/placement new/重载new delete
new当使用new的时候,实际上调用的是operator new,operator new在<new>头文件中://@{/** These are replaceable signatures: * - normal single new and delete (no arguments, throw @c bad_alloc on error) * - normal ...原创 2020-03-19 11:10:52 · 153 阅读 · 0 评论