美文网首页
C++ 面试问题准备4

C++ 面试问题准备4

作者: HenryTien | 来源:发表于2017-04-05 08:22 被阅读12次

Memory Allocation/Deallocation

What is the difference between new/delete and malloc/free?
What is difference between new and malloc?

What is the difference between delete and delete[]?

What is difference between malloc()/free() and new/delete?
What is the difference between "new" and "operator new" ?
What is Memory alignment??

Is there a way to force new to allocate memory from a specific memory area?
How does free know the size of memory to be deleted.?
Can I free() pointers allocated with new? Can I delete pointers allocated with malloc()?
Why should I use new instead of trustworthy old malloc()?

Can I use realloc() on pointers allocated via new?
Do I need to check for NULL after p = new Fred()?
Do I need to check for NULL before delete p?
What are the two steps that happen when I say delete p?
In p = new Fred(), does the Fred memory "leak" if the Fred constructor throws an exception?

How do I allocate / unallocate an array of things?

What if I forget the [] when deleteing array allocated via new T[n]?

Can I drop the [] when deleteing array of some built-in type (char, int, etc)?

After p = new Fred[n], how does the compiler know there are n objects to be destructed
during delete[] p?
After p = new Fred[n], how does the compiler know there are n objects to be destructed
during delete[] p?

In p = new Fred(), does the Fred memory "leak" if the Fred constructor throws an exception?

相关文章

  • C++ 面试问题准备4

    Memory Allocation/Deallocation What is the difference bet...

  • 【面试】问题准备(4)

    【表达通用法则】 1,多使用“问题的关键在于”,“为了解决这个问题,我先后采用了三个有力的措施”,“解决方案有一下...

  • c++ 面试问题准备3

    Ploymorphism What is Polymorphism?? What is problem with ...

  • C++ 面试问题准备2

    先看问题:在后面的文章中会给出答案:|)Q: Can one constructor of a class cal...

  • c++ 面试问题准备 指针

    pointers What is a dangling pointer?What is Memory Leak?W...

  • 2019-03-19

    今天开始准备C++面试。0基础学习C++。一直更新到拿到C++的offer。

  • 面试常见问题 - 目录

    面试常见问题01 - C++相关(施工ing) 面试常见问题02 - 算法与数据结构(施工ing) 面试常见问题0...

  • C++ 内存模型(1)--static

    面试过C++的同学都知道,面试官最喜欢问的问题之一就是C++内存模型问题。例如static 、堆、栈等网上对这方面...

  • C和C++的区别和联系(扩展知识)

    复习整理:C/C++区别与联系; 关于C和C++的区别是面试中经常会被问到的问题,本着即将面试的心态,进行知识整理...

  • go语言的++/--操作

    go语言的++/--操作 C/C++程序员的窘境 C/C++程序员在面试的时候经常会被面试官问到++/--的问题而...

网友评论

      本文标题:C++ 面试问题准备4

      本文链接:https://www.haomeiwen.com/subject/grkigttx.html