Thread: What is the major difference between C and C++?

  1. #1
    Registered User
    Join Date
    Oct 2021
    Posts
    1

    Exclamation What is the major difference between C and C++?

    I am pretty good at C but in C++ I am not, Could you please help me to understand what are the top 3 main differences between them.Thank you.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    38,796
    What is the major difference between C and C++ at DuckDuckGo

    And no, you're not going to understand C++ just by knowing the differences (of which there are many).
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Oct 2019
    Posts
    46
    You might as well think of them as two completely different development languages. Like you will usually find me doing.

    o.O

  4. #4
    Registered User
    Join Date
    Oct 2021
    Posts
    1
    Hi Pankaj,

    I agree with Salem, If you are looking to learn C++ you cannot get anywhere just by knowing the differences. However in case you are just curious about knowing the differences, I can help state a few below.

    The Key difference between C and C++ is that they are two different computer programming languages. C++ was developed from the C programming language; however they are quite different in nature. C is a procedure oriented language, whereas C++ supports both procedural and object oriented programming, therefore it is often called a hybrid language.

    C provides calloc() and malloc() for dynamic memory allocation, and free() for memory deallocation. C++ provides the new operator for memory allocation and the delete operator for memory deallocation.

    C supports procedural programming paradigms for code development. C++ is a hybrid language that supports both procedural and object-oriented models.

    Since C does not support encapsulation, data and functions are separate and act as free entities. C++ supports encapsulation, so its data and functions are encapsulated together in the form of an object.

    Check out this reference which talks about the differences between C and C++.

  5. #5
    Registered User
    Join Date
    Oct 2019
    Posts
    46
    Quote Originally Posted by Doodle Bug View Post

    The Key difference between C and C++ is that they are two different computer programming languages. C++ was developed from the C programming language; however they are quite different in nature. C is a procedure oriented language, whereas C++ supports both procedural and object oriented programming, therefore it is often called a hybrid language.
    There is a chance that my familiarity with this subject does not qualify me to comment on this but.

    C++ code implementing certain patterns compared to C code implementing the same pattern or even data structure will usually tend to be completely different. This has lead me to believe that these two languages should be treated as two completely different languages.

    Let alone patterns, data structures

    Speaking of which, is it not possible to implement encapsulation with C? Is this not what 'opaque' objects implement?

  6. #6
    Registered User rstanley's Avatar
    Join Date
    Jun 2014
    Location
    New York, NY
    Posts
    869
    Quote Originally Posted by ghoul View Post
    There is a chance that my familiarity with this subject does not qualify me to comment on this but.

    C++ code implementing certain patterns compared to C code implementing the same pattern or even data structure will usually tend to be completely different. This has lead me to believe that these two languages should be treated as two completely different languages.

    Let alone patterns, data structures

    Speaking of which, is it not possible to implement encapsulation with C? Is this not what 'opaque' objects implement?
    For creating a library, encapsulation can be simulated with header files that are part of the library source, but not part of the API. Users of the compiled library can't see or make use of any functions or structs in that hidden header file, but can be accessed and used by the API functions.

  7. #7
    Registered User
    Join Date
    Oct 2019
    Posts
    46
    Quote Originally Posted by rstanley View Post

    For creating a library, encapsulation can be simulated with header files that are part of the library source, but not part of the API. Users of the compiled library can't see or make use of any functions or structs in that hidden header file, but can be accessed and used by the API functions.
    That sounds like a decent strategy to me.

    Some would say it is hacky but away from the scholary world, no-one cares for code for as long it implements functionality, patterns etc as expected.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need major c help
    By lantzvillian in forum C Programming
    Replies: 12
    Last Post: 09-28-2010, 04:25 PM
  2. cs major
    By jackstify in forum C++ Programming
    Replies: 12
    Last Post: 07-24-2006, 06:08 PM
  3. Major Windows Software - Are there any Major Players Left?
    By Davros in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 11-12-2004, 05:34 PM
  4. Major Changes to Site
    By webmaster in forum A Brief History of Cprogramming.com
    Replies: 55
    Last Post: 04-07-2004, 04:54 AM
  5. Need major help
    By Unregistered in forum C++ Programming
    Replies: 5
    Last Post: 10-09-2001, 10:04 AM

Tags for this Thread