Sat 06 March 2010

Every language has its flaws - C++

Scott Meyers auf die Frage, welche drei Dinge er am wenigsten mag in C++:

I'd like to answer this question with "complexity, complexity, complexity!", but naming the same thing three times is cheating. Still, I think that C++'s greatest weakness is complexity. For almost every rule in C++, there are exceptions, and often there are exceptions to the exceptions. For example, const objects can't be modified, unless you cast away their constness, in which case they can, unless they were originally defined to be const, in which case the attempted modifications yield undefined behavior.

Das gesamte (zugegebenermaßen schon etwas ältere) Interview gibt es hier.

Thu 31 December 2009

Der "läuft gegen"-Operator in C++

#include <iostream>

int main(int argc, char **argv)
    int x = 10;

    // x goes to 0
    while (x --> 0)
        std::cout << x << std::endl;