Let\'s say I have a simple Movie object that just keeps track of a few data members of name, length and cost.
If in my driver file, I create a Movie object. Which is pre
Memory will be allocated for both:
Movie firstMovie("Titanic", 126, 13.2);
and
Movie* firstMovie = new Movie("Titanic", 126, 13.2);
the difference is first one will be destructed as soon as it comes out of scope where second one will remain same until you delete separately. The second method is called dynamic memory allocation and memory will be allocated in heap where for the first case memory will be allocated in stack.