Jump to content

C++: Difference between revisions

323 bytes added ,  26 November 2019
no edit summary
No edit summary
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
__FORCETOC__
__FORCETOC__
C++ is a very popular and powerful language which includes all the low-level features of [[C_(programming_language) | C]] (e.g. pointers, operator overloading) along many high-level features (regex, STL containers) thanks to the C++ standard library.<br>
Some people may think of it as an object-oriented version of C.


==Usage==
==Usage==
Line 50: Line 52:
This will allocate an array in the heap.<br>
This will allocate an array in the heap.<br>


[https://shendrick.net/Coding%20Tips/2015/03/15/cpparrayvsvector.html array vs vector]
[https://shendrick.net/Coding%20Tips/2015/03/15/cpparrayvsvector.html array vs vector]<br>
If you need a static sized array, you can use <code>std::array</code> in the <code>array</code> header.<br>
If you need a static sized array, you can use <code>std::array</code> in the <code>array</code> header.<br>
This wrapper around C-style arrays gives us size information and allows the array to be passed around by reference while keeping the array on the stack unlike <code>std::vector</code>.<br>
This wrapper around C-style arrays gives us size information and allows the array to be passed around by reference while keeping the array on the stack unlike <code>std::vector</code>.<br>