Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C vs. C++

Name: Anonymous 2012-02-22 8:39

C++ is
- more type safe
- safer memory management (unique_ptr, smart_ptr, weak_ptr)
- classes with destructors (RAII is nice)
- generic containers in standard library (no need to implement dynamic array for every other project)

C is
- cleaner
- simpler and easier to learn


C is nice for beginners, but real programmers use C++.

Name: Anonymous 2012-02-22 11:23

#include <iostream>

int main() {
    int c, cpp;

    c = 42;
    cpp = c++;
    if (cpp > c)
        std::cout << "C++ is superior to C" << std::endl;
    else if (c > cpp)
        std::cout << "C is superior to C++" << std::endl;
    else
        std::cout << "C/C++ are equal" << std::endl;
    return 0;
}


$ g++ main.cc
$ ./a.out
C is superior to C++


There you have it. C++ itself hath spoken.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List