|
When to use the new keyword in C++?
How do you know when to use the new keyword when creating new objects in C++? For example, what is the difference between string str("hello"); and string *strptr = new string("hello"); and when should you use one over the other? I know strptr is a pointer and str is not -- is that the only difference? Also, what is the difference between the two regarding how they are created in memory?
|