Pointer to classes

So i was reading the Cplusplus tutorials for some recap on Polymorphism and I saw:

1
2
   Polygon poly;
   Polygon* ppoly3 = &poly;


So im left wondering if maybe it would be the same thing as

 
   Polygon* ppoly3 = new Polygon();


Im just stuck on polymorphism a bit so even if im completely wrong, what would be the difference?

First off, that has nothing to do with polymorphism.

The two examples are not the same; the first creates a pointer to an object created on the stack, and the second allocates memory for an object that is created on the heap.
Well actually it does have something to do with polymorphism because that concept can't be implemented without pointers.
Cody0023 wrote:
Well actually it does have something to do with polymorphism because that concept can't be implemented without pointers.
Not only is that statement completely wrong, it's like saying that essays are related to fingers because essays can't be written without fingers.
I think he means that you cant do polymorphism without that concept? eitherways, that concept i learned in the polymorphism tutorial, thats why i came across it...i know thats not what polymorphism is...
Last edited on
I didn't mean to sound rude - I was just trying to emphasize you can perform polymorphism just fine without pointers. I'm not very good at not sounding rude though.
No not really rude just random XD eitherways the question is solved (more or less) so ill just mark as solved :P
without pointers or references i meant.
That still makes no sense whatsoever.
Topic archived. No new replies allowed.