virtual

Why doesn't polymorphism work without pointers/references?

柔情痞子 提交于 2019-11-25 23:25:20
问题 I did find some questions already on SO with similar title- but when I read the answers they were focussing on different parts of the question which were really specific (e.g. STL/containers).. Could someone please show me why you must use pointers/references for implementing polymorphism? I can understand pointers may help- but surely references only differentiate between pass-by-value and pass-by-reference?? Surely so long as you allocate memory on the heap- so that you can have dynamic