Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • Thanks for the advices. I don't really get why I should avoid writing object-oriented code, though; or did you mean some parts of OOP specifically? Commented Feb 1, 2011 at 16:36
  • 1
    OOP does not solely mean programming with objects, it implies certain design-patterns, runtime polymorphism through inheritance, class hierarchies ... C++ is not really great in expressing these - you need (smart) pointers and often explicit memory management for runtime polymorphism, it's relatively slow and full of pitfalls (ever forgot a virtual destructor?). You often have cleaner ways of expressing the same with pure objects and e.g. generic programming / static polymorphism. Commented Feb 1, 2011 at 18:52
  • 2
    @Niphra: it's not about not using OOP, it's about not restraining yourself to OOP. C++ offers multiple paradigms, and good C++ programs use most, if not all, of them. Commented Feb 1, 2011 at 18:55
  • 3
    None of these are idioms. The OOP advice is questionable at best and seems to rely on fear rather than any technical reason. Commented Feb 10, 2011 at 18:20
  • "ever forgot a virtual destructor". Yes - important to turn on compiler warnings. Another one: 'function returning a value may not actually return a value' - in a case where the returned value requires a constructor. kaboom. IMHO that warning should be on by default. Commented Sep 5, 2014 at 16:55