C++: Difference between revisions

290 bytes added ,  7 October 2019
Line 87: Line 87:
After using <code>new</code> to allocate an object, use <code>delete</code> to deallocate it.  <br>
After using <code>new</code> to allocate an object, use <code>delete</code> to deallocate it.  <br>
You can also use C allocation with <code>malloc</code>, <code>calloc</code>, <code>alloca</code>, and <code>free</code>, though it is [https://stackoverflow.com/questions/184537/in-what-cases-do-i-use-malloc-and-or-new not recommended] since these are not type-safe.<br>
You can also use C allocation with <code>malloc</code>, <code>calloc</code>, <code>alloca</code>, and <code>free</code>, though it is [https://stackoverflow.com/questions/184537/in-what-cases-do-i-use-malloc-and-or-new not recommended] since these are not type-safe.<br>
===Casting===
[https://stackoverflow.com/questions/332030/when-should-static-cast-dynamic-cast-const-cast-and-reinterpret-cast-be-used Types of casts]
C++ has several types of casts.
These are the main ones.
* <code>const_cast</code>
* <code>static_cast</code>
* <code>dynamic_cast</code>


==Programming Styles==
==Programming Styles==