I would like to know for example if to allocate memory dynamically I use new [] or malloc in std :: vector, or do not need, if I do not need, where should I use new [], malloc and smartpointers?
            Asked
            
        
        
            Active
            
        
            Viewed 162 times
        
    -7
            
            
        - 
                    11Sound like you could use a [good C++ book](http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list) – NathanOliver Jun 19 '17 at 00:27
- 
                    Possible duplicate of [Why should C++ programmers minimize use of 'new'?](https://stackoverflow.com/questions/6500313/why-should-c-programmers-minimize-use-of-new) – Jun 19 '17 at 04:30
1 Answers
-4
            If you use c++, you would better use new [] method to allocate memory in heap because it is more safe than malloc method.
 
    
    
        Mark
        
- 18
- 5
- 
                    3While using `malloc` should be avoided in C++ code, if you use the STL, then you almost never should need to use `new[]` directly. – jamesdlin Jun 19 '17 at 00:57
