Another newbie question here =-) This one comes from a difference in Java and C++ syntax. In Java, as I understand it, whenever you define an object of a class, you have to use this format:
ClassName object1 = new ClassName(int parameter1);
But in C++ they have two ways to define an object of a class:
className object1(int parameter);
className object1 = new className(int parameter);
Why does C++ have 2 ways to do this? What''s the difference between using "new" and not using it?
"I''''m not evil... I just use the power of good in evil ways."
The version using "new" isn''t limited to the scope of the declaration. It stays on the heap until you use "delete" for that variable. If you don''t call ever delete, you get a memory leak (there''s no garbage collection in C/C++, remember; you have to do it yourself).