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
You can simply instantiate the object like this:
Movie firstMovie ("Titanic", 126, 13.2);
You have to use the new keyword when you are initializing raw pointers.
Movie *firstMovie = new Movie("Titanic", 126, 13.2);
The difference is that the pointer object uses ->
when accessing member functions while the other object uses the .
notation. Also the pointer object is allocated in the heap while the other one is allocated in the stack.