B
Bern
what are all the diferences between the two?
Bern said:what are all the diferences between the two?
what are all the diferences between the two?
The main difference is in the personalities of people who program in
these languages.
People who program in C are level headed and precise. People who
program in C++ like to boast that it is a very complicated language
that takes time to master - that's why most of their code appears
unintelligible.
Or it could be that they're all a bunch of willy wavers doing the
technological equivalent of wearing the emperor's new cloths.
what are all the diferences between the two?
Bern said:what are all the diferences between the two?
Bradley said:The main difference is in the personalities of people who program in
these languages.
People who program in C are level headed and precise. People who
program in C++ like to boast that it is a very complicated language
that takes time to master - that's why most of their code appears
unintelligible.
Or it could be that they're all a bunch of willy wavers doing the
technological equivalent of wearing the emperor's new cloths.
And some people write C code claiming it to be C++ just because they areLNK2005 said:" Bern" <[email protected]> skrev i meddelandet news:[email protected]...
A few major C++ features not available in C:
- Classes
- Templates
- Exception handling
- Function overloading
- Operator overloading
- Namespaces
- Standard library for templated collections, strings, common algorithms,
etc.
And a few minor ones:
- bool type
- Reference types
- Somewhat stricter type checking than C
- new/delete instead of malloc()/free()
- New syntax for declaring struct types
C++ is obviously more complex than C, but many of the added features are
designed to make life easier (string handling is a good example). Some
programmers like to use C++ as "a better C". Others think that the OO
features in C++ makes it more suitable for larger projects than C. Still
others prefer the relative simplicity and sparsity of C.
To explain the difference by enumerating features just gives part of the
picture. Another way to say it is that C++ is a multi-paradigm language,
with support for procedural, object-oriented and generic programming, while
C supports procedural programming only (it's possible to write OO code with
C, but it's not pretty). If this is a good or a bad thing is obviously a
matter of opinion. IMHO the standard library alone makes C++ worth the extra
learning effort.
And some people write C code claiming it to be C++ just because they are
using cout.
JKop said:Bern posted:
The main difference is a thing called a "class". In C, you can group
variables together, like:
struct Dog
{
unsigned age;
const char* name;
bool has_a_tail;
};
In C++, you can add functions in with these structures:
struct Dog
{
unsigned age;
const char* name;
bool has_a_tail;
unsigned CalculateTailLength();
unsigned CalculateYearsToLive();
}
A structure which includes functions is referred to as a class.
C++ is really C with more features added, the main ones of which are:
Classes
References
But on top of that there are some actual changes, eg. in C:
void Blah();
that declares a function that takes any amount of arguments, while in C++ it
declares a function which take no arguments at all.
But at the end of it all: C++ is C with more features.
-JKop
LNK2005 said:A few major C++ features not available in C:
- Classes
- Templates
- Exception handling
- Function overloading
- Operator overloading
- Namespaces
- Standard library for templated collections, strings, common algorithms,
etc.
And a few minor ones:
- bool type
- Reference types
- Somewhat stricter type checking than C
- new/delete instead of malloc()/free()
Bern said:what are all the diferences between the two?
Thomas Matthews said:Thomas Matthews wrote
What about function overloading?
What about the "const" modifier?
Inheritance?
Public, private and protected accesses?
Mutable?
operators new and delete?
Actually, if you were to write a compiler for each, you would
recognize that they are two different languages that share
some things. C++ is not C with more features.
LNK2005 said:A few major C++ features not available in C:
- Classes
- Templates
- Exception handling
- Function overloading
- Operator overloading
- Namespaces
- Standard library for templated collections, strings, common algorithms,
etc.
Another way to say it is that C++ is a multi-paradigm language,
with support for procedural, object-oriented and generic programming, while
C supports procedural programming only (it's possible to write OO code with
C, but it's not pretty). If this is a good or a bad thing is obviously a
matter of opinion. IMHO the standard library alone makes C++ worth the extra
learning effort.
Thomas Matthews said:Actually, if you were to write a compiler for each, you would
recognize that they are two different languages that share
some things. C++ is not C with more features.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.