Differences between C and C++

This is a discussion on Differences between C and C++ within the C++ Programming forums, part of the General Programming Boards category; I was wondering what are the differences between C and C++? I'm wondering because of the fact that I can ...

  1. #1
    Registered User
    Join Date
    Jul 2005
    Posts
    100

    Differences between C and C++

    I was wondering what are the differences between C and C++? I'm wondering because of the fact that I can follow along most C code and understand it. I know classes are new (and recently, namespace std) but what else?

  2. #2
    myNegReal
    Join Date
    Jun 2005
    Posts
    100
    The STL, all kinds of little additions, I think new and delete are new to C++ or do they work in C?
    Using Dev-C++ on Windows

  3. #3
    Registered User
    Join Date
    Mar 2002
    Posts
    1,595
    new and delete as well as new[] and delete[] are specific for C++ and will not work in C, though malloc() and free() which are the equivalent in C (and are probably hidden somewhere in new and delete) will work in C++.

    Structs in C++ work differently than in C. Inheritance and polymorphism are offshoots of classes and therefore not available in C.
    You're only born perfect.

  4. #4
    aoeuhtns
    Join Date
    Jul 2005
    Posts
    581
    C++ has templates.

  5. #5
    Registered User
    Join Date
    Jan 2005
    Posts
    7,317
    They are very different from a design aspect. C focuses on procedural programming, while C++ focuses on object oriented and generic programming.

  6. #6
    *this
    Join Date
    Mar 2005
    Posts
    498
    On a side note, C++ is not a superset of C.

    The superset of C is "C with classes".

    Structs are used differently (calling methods, ie you have to type struct before you create an object of a struct type)

    Another thing C++ has is operator overloading

  7. #7
    VA National Guard The Brain's Avatar
    Join Date
    May 2004
    Location
    Manassas, VA USA
    Posts
    903
    c
    Code:
    malloc( )
    printf( )
    sprintf( )
    fgets( ) 
    char[ ]
    free
    int number = (int)'A' ;


    c++
    Code:
    new
    cout 
    <<
    cin
    >>
    string
    delete
    int number = static_cast<int>('A');
    class {  };
    struct{  };
    Last edited by The Brain; 07-25-2005 at 09:08 PM.
    • "Problem Solving C++, The Object of Programming" -Walter Savitch
    • "Data Structures and Other Objects using C++" -Walter Savitch
    • "Assembly Language for Intel-Based Computers" -Kip Irvine
    • "Programming Windows, 5th edition" -Charles Petzold
    • "Visual C++ MFC Programming by Example" -John E. Swanke
    • "Network Programming Windows" -Jones/Ohlund
    • "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
    • "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel

  8. #8
    aoeuhtns
    Join Date
    Jul 2005
    Posts
    581
    Quote Originally Posted by The Brain
    Code:
    int number = (char)'A' ;
    Why would you typecast a char into a char before assigning to an int??

  9. #9
    VA National Guard The Brain's Avatar
    Join Date
    May 2004
    Location
    Manassas, VA USA
    Posts
    903
    oh my bad.. i'll edit
    • "Problem Solving C++, The Object of Programming" -Walter Savitch
    • "Data Structures and Other Objects using C++" -Walter Savitch
    • "Assembly Language for Intel-Based Computers" -Kip Irvine
    • "Programming Windows, 5th edition" -Charles Petzold
    • "Visual C++ MFC Programming by Example" -John E. Swanke
    • "Network Programming Windows" -Jones/Ohlund
    • "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
    • "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel

  10. #10
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    Quote Originally Posted by blankstare77
    I was wondering what are the differences between C and C++?
    http://david.tribble.com/text/cdiffs.htm
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  11. #11
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,801
    One is good and well the other is good .
    Woop?

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21