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
Printable View
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
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.
forgot both C and C++. Go for basic it does even more than either!!!!!!!
forget about c.. c++.. java.. basic... grow some kahoonas and code completely in machine language. :eek:
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.Quote:
Originally Posted by Vicious
Quzah.
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.Quote:
Originally Posted by quzah
[note] If I'm not mistaken, in C++'s early years it was refered to as C with classes. ;)
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++.
So you can have variable length arrays in C++?Quote:
There's nothing that can be done with C that can't be done with 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.
>>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?
>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.
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++.
Not on all machines. On some machines the sizeof (void *) is different then sizeof(char *)Quote:
Originally Posted by Hunter2
Even so there are some things that C can do that C++ can not even if there is a way to simulate them.Quote:
There's a C way to do things and there's a C++ way to do things.
Lower-level != faster in all cases.Quote:
Some will claim that C is actually faster because its a "lower-level" language
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.Quote:
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 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.