Advantage of C to C++

This is a discussion on Advantage of C to C++ within the C++ Programming forums, part of the General Programming Boards category; Hi, I have heard that C++ is almost a superset of C. Can anyone please tell me what can one ...

  1. #1
    Registered User
    Join Date
    Jun 2004
    Posts
    23

    Advantage of C to C++

    Hi,
    I have heard that C++ is almost a superset of C. Can anyone please tell me what can one do in C which we can't in C++


    Thanks

  2. #2
    Registered User axon's Avatar
    Join Date
    Feb 2003
    Posts
    2,572

    some entropy with that sink? entropysink.com

    there are two cardinal sins from which all others spring: Impatience and Laziness. - franz kafka

  3. #3
    i dont know Vicious's Avatar
    Join Date
    May 2002
    Posts
    1,200
    C++ is an object oriented programming language. Usually programs in c++ can be more organized as far as structure. Some will claim that C is actually faster because its a "lower-level" language. I cant state if one is faster or not, I honestly dont know. And C++ really is C. Anything that is C is C++.. C++ just has extended features. But I like to look at them as two separate laguages. I usually dont like to mix the two but thats just me.
    What is C++?

  4. #4
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,812
    forgot both C and C++. Go for basic it does even more than either!!!!!!!
    Woop?

  5. #5
    VA National Guard The Brain's Avatar
    Join Date
    May 2004
    Location
    Manassas, VA USA
    Posts
    903

    Talking

    forget about c.. c++.. java.. basic... grow some kahoonas and code completely in machine language.
    • "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

  6. #6
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by Vicious
    C++ is an object oriented programming language.
    Not really, but it sure tries to be. It isn't an "entirely OO" language. That is to say you can code to your hearts content in C++ without ever using any OO behaviour or style at all. Thus, it isn't a true OO language. It wants to be though.

    Quzah.
    Hope is the first step on the road to disappointment.

  7. #7
    i dont know Vicious's Avatar
    Join Date
    May 2002
    Posts
    1,200
    Quote Originally Posted by quzah
    It wants to be though.
    Yeah C++ I shouldnt have said it was an OO language, yet should have said it has OO "features". Unless I'm mistaken ( correct me if I'm wrong ) C# is purely OO.

    [note] If I'm not mistaken, in C++'s early years it was refered to as C with classes.
    Last edited by Vicious; 09-19-2004 at 11:56 PM.
    What is C++?

  8. #8
    Registered User
    Join Date
    Nov 2002
    Posts
    126
    C++ is an object-oriented language. It facilitates all of the main principles of object orientation( data abstraction, inheritance, polymorphism, etc. ), and it allows for you to express your program in terms of objects instead of modules or functions. It is not a pure object oriented language like Java, Smalltalk, or Eiffel which force you to express your program entirely with objects. The great thing about C++ is that it supports all of the major programming paradigms and styles, but it does not force any one of them, allowing the programmer to express their program with the paradigm they deem most fit. C++ brings a lot more to the table than just object orientation, and I find it hard to refer to C++ as a mere superset of C, though I suppose it technically is. There's nothing that can be done with C that can't be done with C++.

  9. #9
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    There's nothing that can be done with C that can't be done with C++.
    So you can have variable length arrays in C++?
    You can not cast void * when assigning to another pointer in C++?

    There are things that C++ can not do that C can do. Most of it is pretty minor and trival but they do exist.
    Last edited by Thantos; 09-20-2004 at 08:02 AM.

  10. #10
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    >>You can not cast void * when assigning to another pointer in C++?
    Isn't void* practically the same as unsigned char* (or char*), other than the fact that you can't dereference it?
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  11. #11
    Registered User
    Join Date
    Nov 2002
    Posts
    126
    >So you can have variable length arrays in C++?

    You'd have to allocate them dynamically but yes. Or in cases where appropriate, you could use a vector

    >You can not cast void * when assigning to another pointer in C++?

    You'll almost never need to use void pointers in C++(as my highly criticized sig would indicate)

    There's a C way to do things and there's a C++ way to do things. If you use C-inspired code with C++, you might run into some slight pitfalls here and there, but the general idea is that C++ can do anything that C can.

  12. #12
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    If you're programming on microcontrollers and the like, you are more likely to be using C than C++ (as it is, I believe, considered too bloated for such applications), but perhaps someone with more experience with this can elaborate.

    C++ and C are not entirely compatible, but largely are. Most C code that I have run into in general applications would be perfectly legal (or very close) in C++.

  13. #13
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Quote Originally Posted by Hunter2
    >>You can not cast void * when assigning to another pointer in C++?
    Isn't void* practically the same as unsigned char* (or char*), other than the fact that you can't dereference it?
    Not on all machines. On some machines the sizeof (void *) is different then sizeof(char *)

    There's a C way to do things and there's a C++ way to do things.
    Even so there are some things that C can do that C++ can not even if there is a way to simulate them.

    Some will claim that C is actually faster because its a "lower-level" language
    Lower-level != faster in all cases.

    When I was doing a report on Pascal vs C I wrote some basic test programs and the pascal program ran faster then the C program.

  14. #14
    i dont know Vicious's Avatar
    Join Date
    May 2002
    Posts
    1,200
    Lower-level != faster in all cases.

    When I was doing a report on Pascal vs C I wrote some basic test programs and the pascal program ran faster then the C program.
    I know, I wish some one ( with more know-how than myself ) would do a few tests with C and C++ to see if one is infact faster than another. And if there is enough difference to actually affect preformance.
    What is C++?

  15. #15
    Registered User manofsteel972's Avatar
    Join Date
    Mar 2004
    Posts
    317
    ??I always thought that Object Oriented Programming was a style of programming? You can use any language as far as i know even assembly language to program in OOP. As long as you adhere to its principles.
    "Knowledge is proud that she knows so much; Wisdom is humble that she knows no more."
    -- Cowper

    Operating Systems=Slackware Linux 9.1,Windows 98/Xp
    Compilers=gcc 3.2.3, Visual C++ 6.0, DevC++(Mingw)

    You may teach a person from now until doom's day, but that person will only know what he learns himself.

    Now I know what doesn't work.

    A problem is understood by solving it, not by pondering it.

    For a bit of humor check out xkcd web comic http://xkcd.com/235/

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Speed/size advantage to SQL?
    By MK27 in forum Tech Board
    Replies: 15
    Last Post: 06-26-2009, 12:28 PM
  2. advantage of a hash table
    By alyssa in forum Linux Programming
    Replies: 3
    Last Post: 03-02-2009, 09:04 AM
  3. Advantage of C in computer graphics?
    By NoobieGecko in forum C Programming
    Replies: 8
    Last Post: 08-29-2008, 05:55 PM
  4. taking advantage of hyperthreading?
    By doubleanti in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 08-22-2006, 12:49 AM
  5. Advantage to having IP-only access to the boards...
    By -KEN- in forum A Brief History of Cprogramming.com
    Replies: 17
    Last Post: 08-31-2002, 08:27 PM

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