#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    142
    Rep Power
    1

    Difference between c and c++


    There are articles that explain the technical differences between the two languages, but that's not what I want to know.
    Often, when I look for an answer to a question for C, I come across articles on the same topic for C++.
    I want to know if it's safe to read these articles for C++, and assume that the explanation holds for C as well.
  2. #2
  3. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,091
    Rep Power
    2222
    For the most part, yes.

    There are a few ways to look at C++, but basically C++ is a super-set of C, meaning that it is largely just C with other capabilities added on. With very few exceptions, you should be able to take just about any C program and compile it as C++.

    What you would have to look out for would be if that C++ example uses a feature that C does not have. Such as function overloading (having multiple functions with the exact same name, but different numbers and types of parameters), being able to declare variables in the midst of code (though this was added in C99), or of course using new and delete for dynamic allocation or iostreams. So understand that the C++ example might not compile successfully as C.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    142
    Rep Power
    1
    I see, thank you.

IMN logo majestic logo threadwatch logo seochat tools logo