Hi Dan,
My 2 cents worth of advice after the gold already offered !!
I am discovering that about 90% of my programming knowledge is straight c. |
I hope that you learn to use the STL containers & algorithms as quickly as possible: to avoid mixing C++ and C programming. It's just that it is a common mistake to write loops to process things one at a time, when there is very often an C++ algorithm that will process a whole container worth of stuff for you.
I know c++ boasts dynamic memory, .... |
malloc
is a type dynamic memory for C. A bit pedantic I know ....
With C++03, people were taught to use
new
and
delete
, but big problems exist with this idea - namely when an exception is thrown before code reaches the call to
delete
. This idea might be rushing you a bit, but here goes ...
With C++11, we have RAII (Reference Acquisition Is Initialisation) smart pointers, which don't suffer this problem. So people are now taught to use these, and never use
new
and
delete
again. However it is still good to know how they work because they exist in recent production code, one day you may be forced to work with them.
does that mean that new will behave just like malloc if I do something like this? |
I hope this doesn't imply you are trying to make your C++ program mimic the functionality of a C program? I might be wrong about what you are thinking, so apologies if this is the case. It's just that C++ does a lot of things (not all) better than C, and I hope you can embrace the better flexibility & robustness (at least less work to ensure it doesn't break) of C++
Any way just putting ideas out there man, hopefully they are potentially useful for you, if not now then some time in the future. If you already know all this (it's hard to guess how much people know), then no harm done :+)
Regards