Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I agree with most posts there: C++ is a multi-paradigm language, so the "hidden" features you'll find (other than "undefined behaviours" that you should avoid at all cost) are clever uses of facilities.</p> <p>Most of those facilities are not build-in features of the language, but library-based ones.</p> <p>The most important is the <strong>RAII</strong>, often ignored for years by C++ developers coming from the C world. <strong>Operator overloading</strong> is often a misunderstood feature that enable both array-like behaviour (subscript operator), pointer like operations (smart pointers) and build-in-like operations (multiplying matrices.</p> <p>The use of <strong>exception</strong> is often difficult, but with some work, can produce really robust code through <strong>exception safety</strong> specifications (including code that won't fail, or that will have a commit-like features that is that will succeed, or revert back to its original state).</p> <p>The most famous of "hidden" feature of C++ is <strong>template metaprogramming</strong>, as it enables you to have your program partially (or totally) executed at compile-time instead of runtime. This is difficult, though, and you must have a solid grasp on templates before trying it.</p> <p>Other make uses of the multiple paradigm to produce "ways of programming" outside of C++'s ancestor, that is, C.</p> <p>By using <strong>functors</strong>, you can simulate functions, with the additional type-safety and being stateful. Using the <strong>command</strong> pattern, you can delay code execution. Most other <strong>design patterns</strong> can be easily and efficiently implemented in C++ to produce alternative coding styles not supposed to be inside the list of "official C++ paradigms".</p> <p>By using <strong>templates</strong>, you can produce code that will work on most types, including not the one you thought at first. You can increase type safety,too (like an automated typesafe malloc/realloc/free). C++ object features are really powerful (and thus, dangerous if used carelessly), but even the <strong>dynamic polymorphism</strong> have its static version in C++: the <strong>CRTP</strong>.</p> <p>I have found that most "<em>Effective C++</em>"-type books from Scott Meyers or "<em>Exceptional C++</em>"-type books from Herb Sutter to be both easy to read, and quite treasures of info on known and less known features of C++.</p> <p>Among my preferred is one that should make the hair of any Java programmer rise from horror: In C++, <strong>the most object-oriented way to add a feature to an object is through a non-member non-friend function, instead of a member-function</strong> (i.e. class method), because:</p> <ul> <li><p>In C++, a class' interface is both its member-functions and the non-member functions in the same namespace</p></li> <li><p>non-friend non-member functions have no privileged access to the class internal. As such, using a member function over a non-member non-friend one will weaken the class' encapsulation.</p></li> </ul> <p>This never fails to surprise even experienced developers.</p> <p>(Source: Among others, Herb Sutter's online Guru of the Week #84: <a href="http://www.gotw.ca/gotw/084.htm" rel="nofollow noreferrer">http://www.gotw.ca/gotw/084.htm</a> )</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload