quote:Original post by Ready4Dis
Sounds more like a case of bad planning and bad variable naming.
Sounds like you don''t know what you are talking about. My point is that c++ provides mechanisms in the language that you have to hack around as a C developer. All the planning in the world isn''t going to make an C implementation of virtual functions pretty.
Using c++ doesn''t mean having large class heirarchies, or making everything a virtual function. You have that option, and in many cases polymorphism is exactly what you want. In other cases, it falls woefully short(as anyone who has used generic functions in Lisp knows). You don''t have to sacrifice performance for productivity in c++ - you simply have more language idioms available to express your problem.
Did you actually profile your raytracer? I ask because I wrote a raytracer in c++, using a class heirarchy for intersections, and almost no time was spent on virtual function calls - it was all in the intersect code itself, and in the spatial subdivision tree.
Let me reiterate that c++ is hardly the best solution to C. In particular, most of the C features that were included in c++ for compatibility are to blame for c++''s problems. However, properly written c++ is orders of magnitude safer and more productive than C code is. I guarantee you that almost all buffer overruns in c++ code are due to somebody writing C-style code, and wouldn''t exist if the coder used std::string, std::vector, std::stringstream, or such.