View Single Post
Old Mar 9th, 2006, 9:49 PM   #1
titaniumdecoy
Expert Programmer
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 928
Rep Power: 4 titaniumdecoy is on a distinguished road
Send a message via AIM to titaniumdecoy
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?
titaniumdecoy is offline   Reply With Quote