3 ms·
Tangential question for c++ devs: How would this even compile before the author fixed the Sphere* typo in the vector?
by rddbs 2y ago
Tangential question for c++ devs: How would this even compile before the author fixed the Sphere* typo in the vector?
- grg0 2y agoIt really won't. The only reason I could think of is if there were a Sphere(Sphere*) constructor, which would be weird, and is also not the case [1]. There is also no reason to use a vector<Sphere*> since Sphere is not part of an inheritance tree; a vector<Sphere> would've done just fine removing the calls to 'new' in that blog post. Overall, I think this post is on the low end of the quality spectrum. I think the author is a bit confused about things, like they've been doing JS and picked up C++ only recently. Nothing bad about it, but I would do some more reading before posting much of anything. [1] https://github.com/uds5501/multiple-spheres/blob/master/include/shapes/Sphere.h https://github.com/uds5501/multiple-spheres/blob/master/incl...