473,395 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

The difference between C and C++

I was just reading another post when someone commented that the code was C
and not C++. What are the differences? (Examples?) The answer does not
affect my programming but would help to know if I need to post a question.
Jan 13 '06 #1
45 4097
Lindsay wrote:
I was just reading another post when someone commented that the code was C
and not C++. What are the differences? (Examples?) The answer does not
affect my programming but would help to know if I need to post a question.


In short, whereas C supports only the structured programming paradigm,
C++ is a "multi-paradigm" language, which means that it supports
different programming techniques such as structured programming,
object-oriented programming (thanks to inheritance, virtual functions,
strong typing, etc.), and generic programming (thanks to templates).

Almost* any C program can be built unchanged with a C++ compiler, and
the entire C standard library is part of the C++ standard library.
Additionally, C++ has its own standard library, which includes the STL
(standard template library), which consists of generic algorithms and
containers for a variety of uses.
* See http://www.parashift.com/c++-faq-lit....html#faq-6.11.
The C++ version of the C standard language/library is based on a
slightly dated version of the C standard, but this doesn't affect their
compatibility all that much as far as most programs are concerned.

Cheers! --M

Jan 13 '06 #2
Lindsay wrote:
I was just reading another post when someone commented that the code was C
and not C++. What are the differences? (Examples?) The answer does not
affect my programming but would help to know if I need to post a question.


C was invented by Dennis Ritchie in the 1970s.
C++ was invented by Bjarne Stroustrup in the 1980s.

C++ was created as a successor to C. The _main_ difference is support
for object-oriented programming, but there are a number of feature
changes. Quite some detail is gone into here:

http://en.wikipedia.org/wiki/C%2B%2B

It's quite common to describe C++ as a superset of C; this isn't exactly
true:

- a C program may use C++-specific reserved words as identifiers
- some obsolete syntaxes are not part of C++, such as the old way of
specifying the types of function parameters
- some features that were added in C99 have not yet made it into a C++
standard.

Of course, a C program can be, and often is, also a valid C++ program.
However, if it doesn't use any of the features specific to C++, then
it's rather meaningless to call it a C++ program. My guess is that what
whoever it was meant is that a snippet of code that somebody posted
doesn't use any C++-specific features, and as such can be considered
plain C, and therefore more appropriate for comp.lang.c than here.
Maybe if you would care to supply an example, somebody can clarify further.

Stewart.

--
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/M d- s:- C++@ a->--- UB@ P+ L E@ W++@ N+++ o K-@ w++@ O? M V? PS-
PE- Y? PGP- t- 5? X? R b DI? D G e++>++++ h-- r-- !y
------END GEEK CODE BLOCK------

My e-mail is valid but not my primary mailbox. Please keep replies on
the 'group where everyone may benefit.
Jan 13 '06 #3
yeah, i think you can past your code, then we can talk more about why
the snippet is C , not really c++

Jan 13 '06 #4
"Stewart Gordon" <sm*******@yahoo.com> wrote in message
news:dq**********@sun-cc204.lut.ac.uk...

Of course, a C program can be, and often is, also a valid C++ program.
However, if it doesn't use any of the features specific to C++, then it's
rather meaningless to call it a C++ program.


It is not meaningless. It is 100% accurate and 100% meaningful. If it
conforms with the C++ standard, then it is a C++ program. That is the simple
fact. Whether or not it is also a valid C program is irrelevant.

--
John Carson
Jan 13 '06 #5
I see both points, but I'm leaning towards Lyon's side. If it
is purely C, then questions might better be answered in the
comp.lang.c newsgroup. But I also agree with you, John,
that syntactically you can call it a C++ program as it's
compilable with a C++ compiler.

--Randy

Jan 13 '06 #6
Lindsay wrote:
I was just reading another post when someone commented that the code was C
and not C++. What are the differences? (Examples?) The answer does not
affect my programming but would help to know if I need to post a question.


In my opinion, C is an obsolete language. The only reason to post
anything
to comp.lang.c is to communicate with the many people who don't agree
that
C is an obsolete language.

If you post code that could be improved by using other features of C++,
hopefully someone would point that out to you. I don't see the
relevance
if it so happens that the code you post could compile in straight C.

You might want to look at http://www.gotw.ca/resources/clcm.htm for
the guidelines on posting to comp.lang.c++.moderated to help you
decide what you should or shouldn't post.

Jan 13 '06 #7
It will be many, many years (20?) before C is obsolete, if ever. Even
if folks stopped programming in it today, just maintaining the legacy
code would take decades.

Your focus is apparently fairly narrow (x86 platform running Windows?)
since many if not most of the embedded specialty processors (e.g.,
TI's entire line of digital signal processors) use C compilers. There
are still applications out there when an extra MB of memory or
a few hundred MHz of clock speed are very precious resources.

--Randy Yates

Jan 13 '06 #8
wk****@yahoo.com wrote:
Lindsay wrote:
I was just reading another post when someone commented that the code was C
and not C++. What are the differences? (Examples?) The answer does not
affect my programming but would help to know if I need to post a question.

In my opinion, C is an obsolete language. The only reason to post
anything
to comp.lang.c is to communicate with the many people who don't agree
that
C is an obsolete language.


Good thing it's only your opinion :)!

If you post code that could be improved by using other features of C++,
hopefully someone would point that out to you. I don't see the
relevance
if it so happens that the code you post could compile in straight C.

You might want to look at http://www.gotw.ca/resources/clcm.htm for
the guidelines on posting to comp.lang.c++.moderated to help you
decide what you should or shouldn't post.

Jan 13 '06 #9

Randy wrote:
It will be many, many years (20?) before C is obsolete, if ever. Even
if folks stopped programming in it today, just maintaining the legacy
code would take decades.

Your focus is apparently fairly narrow (x86 platform running Windows?)
since many if not most of the embedded specialty processors (e.g.,
TI's entire line of digital signal processors) use C compilers. There
are still applications out there when an extra MB of memory or
a few hundred MHz of clock speed are very precious resources.

--Randy Yates


I looked up "obsolete" in the dictionary, and it appears it can
mean either "no longer is use" or "out of date". I meant to
say that C is out of date.

There must be a common DNA sequence between the
people at the airlines who think it makes sense to
charge more for a flight to Cleavland than a flight to
Detroit that stops in Cleavland, and the people who
think you have to use C instead of C++ for performance
reasons. The only feature in C++ but not C that
impacts size and/or performance even if you don't
use it is exceptions. So far, I haven't seen a C++
compiler that doesn't have an option to disable the
use of execptions.

Jan 13 '06 #10
wk****@yahoo.com wrote:
Randy wrote:
It will be many, many years (20?) before C is obsolete, if ever. Even
if folks stopped programming in it today, just maintaining the legacy
code would take decades.

Your focus is apparently fairly narrow (x86 platform running Windows?)
since many if not most of the embedded specialty processors (e.g.,
TI's entire line of digital signal processors) use C compilers. There
are still applications out there when an extra MB of memory or
a few hundred MHz of clock speed are very precious resources.

--Randy Yates

I looked up "obsolete" in the dictionary, and it appears it can
mean either "no longer is use" or "out of date". I meant to
say that C is out of date.


How do you feel it's "out of date"?

There must be a common DNA sequence between the
people at the airlines who think it makes sense to
charge more for a flight to Cleavland than a flight to
Detroit that stops in Cleavland, and the people who
think you have to use C instead of C++ for performance
reasons. The only feature in C++ but not C that
impacts size and/or performance even if you don't
use it is exceptions. So far, I haven't seen a C++
compiler that doesn't have an option to disable the
use of execptions.


It's Cleveland by the way.
Jan 13 '06 #11
Randy wrote:
It will be many, many years (20?) before C is obsolete, if ever. Even
if folks stopped programming in it today, just maintaining the legacy
code would take decades.

Your focus is apparently fairly narrow (x86 platform running Windows?)
since many if not most of the embedded specialty processors (e.g.,
TI's entire line of digital signal processors) use C compilers. There
are still applications out there when an extra MB of memory or
a few hundred MHz of clock speed are very precious resources.


Agreed, although I program on TI DSPs with C++.

Cheers! --M

Jan 13 '06 #12

Christopher Hulbert wrote:
wk****@yahoo.com wrote:

....
I looked up "obsolete" in the dictionary, and it appears it can
mean either "no longer is use" or "out of date". I meant to
say that C is out of date.


How do you feel it's "out of date"?


Because there is a newer language, C++, that does everything
C does as well as C does, plus it does some other useful
things.

Jan 13 '06 #13

wk****@yahoo.com wrote:
Christopher Hulbert wrote:
wk****@yahoo.com wrote:

...
I looked up "obsolete" in the dictionary, and it appears it can
mean either "no longer is use" or "out of date". I meant to
say that C is out of date.


How do you feel it's "out of date"?


Because there is a newer language, C++, that does everything
C does as well as C does, plus it does some other useful
things.


You obviously haven't done any kernel programming. It can't be done in
C++, not on Linux anyway.

-Brian

Jan 13 '06 #14
I program on TI DSPs with, <gasp>, assembly.

--RY

Jan 13 '06 #15
Randy wrote:
I program on TI DSPs with, <gasp>, assembly.


And I wear shoes that have laces.
Jan 13 '06 #16
BigBrian wrote:
wk****@yahoo.com wrote:
Christopher Hulbert wrote:
wk****@yahoo.com wrote:

...
> I looked up "obsolete" in the dictionary, and it appears it can
> mean either "no longer is use" or "out of date". I meant to
> say that C is out of date.

How do you feel it's "out of date"?


Because there is a newer language, C++, that does everything
C does as well as C does, plus it does some other useful
things.


You obviously haven't done any kernel programming. It can't be done in
C++, not on Linux anyway.

-Brian


Since the original topic of this thread was posting guidelines,
I'd like to suggest that it accomplishes little to post
conclusions with no supporting reasons or arguements.
Unless you're able to make the ground rumble beneath the
feet of anyone reading your post.

Why can't C++ be used in kernel code? The issue I'm aware
of is that it takes special tools to use compiled code in
situations where paging has to be done explicitly. I've
heard these tools do not yet support C++ virtual
function calls or execptions. But C++ is still better than
C even if you don't use virtual function calls or exceptions.
if you use

Jan 13 '06 #17
"Lindsay" <me@home.com> wrote:
I was just reading another post when someone commented that the code was C
and not C++. What are the differences? (Examples?) The answer does not
affect my programming but would help to know if I need to post a question.


Without seeing the code, we can't make a very good guess about what
"someone" was reacting to. There are *many* differences between C++
and C, starting with the "class" keyword. C doesn't have classes, C++
makes *very* heavy use of them. C insists that all variables be
declared at the beginning of a scope, C++ lets you define variables at
the point of use. C++ has templates (and therefore the Standard
Template Library (STL)), C does not. C lets you declare a function
without giving details about parameters, C++ does not. (ie: "void
f();" in C declares a function that could take any number of arguments
of any type, in C++ if declares a function that has no parameters.)
The differences go on and on...

--
Tim Slattery
Sl********@bls.gov
Jan 13 '06 #18
wk****@yahoo.com wrote:

Because there is a newer language, C++, that does everything
C does as well as C does, plus it does some other useful
things.


Untrue. C as of the latest standard has features that are not found in
C++.

Brian
Jan 13 '06 #19
Uh huh. See you in the marketplace.

--RY

Jan 13 '06 #20
Randy wrote:
Uh huh. See you in the marketplace.


Shout when you arrive... I've been here the last 14 years.
Jan 13 '06 #21

Default User wrote:
wk****@yahoo.com wrote:

Because there is a newer language, C++, that does everything
C does as well as C does, plus it does some other useful
things.


Untrue. C as of the latest standard has features that are not found in
C++.

....

Strictly speaking, you're right. But the things that were added
by C99 (and are not in C++) I'd say would either be used
sporadically, or used heavily only in a few applications. The
C++ features not present in C are useful often and in many
applications.

Jan 13 '06 #22
Randy wrote:
Uh huh. See you in the marketplace.

What are you talking about?

Brian

--
Please quote enough of the previous message for context. To do so from
Google, click "show options" and use the Reply shown in the expanded
header.
Jan 13 '06 #23
Then you were watching Sesame Street about the time I was writing
code for a defense company.

--RY

Jan 13 '06 #24
Randy wrote:
Then you were watching Sesame Street about the time I was writing
code for a defense company.

Who was?

Brian

--
Please quote enough of the previous message for context. To do so from
Google, click "show options" and use the Reply shown in the expanded
header.
Jan 14 '06 #25
Randy wrote:
Then you were watching Sesame Street about the time I was writing
code for a defense company.

I don't doubt that. I watch Sesame Street any time I have a chance
these days. Did you mean to offend me with your remark? You need
to do better next time.

Oh, if you have a C++ question, don't forget to include it next time
you post here. With all defense work on DSPs in assembly, you must
be getting confused what we're talking about here.
Jan 14 '06 #26
Interesting point. There have been times when I have posted snippets of code
on this NG, only to be told it's not C++. But I'm using MS C++ .Net Standard
to program with, so it must be C++, yes?

"John Carson" <jc*****@netspace.net.au> wrote in message
news:43**********************@un-2park-reader-01.sydney.pipenetworks.com.au...
"Stewart Gordon" <sm*******@yahoo.com> wrote in message
news:dq**********@sun-cc204.lut.ac.uk...

Of course, a C program can be, and often is, also a valid C++ program.
However, if it doesn't use any of the features specific to C++, then it's
rather meaningless to call it a C++ program.


It is not meaningless. It is 100% accurate and 100% meaningful. If it
conforms with the C++ standard, then it is a C++ program. That is the
simple fact. Whether or not it is also a valid C program is irrelevant.

--
John Carson

Jan 14 '06 #27
I agree. If I'm using MS C++ .Net Standard then I should be posting here,
right?

<wk****@yahoo.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
Lindsay wrote:
I was just reading another post when someone commented that the code was
C
and not C++. What are the differences? (Examples?) The answer does not
affect my programming but would help to know if I need to post a
question.


In my opinion, C is an obsolete language. The only reason to post
anything
to comp.lang.c is to communicate with the many people who don't agree
that
C is an obsolete language.

If you post code that could be improved by using other features of C++,
hopefully someone would point that out to you. I don't see the
relevance
if it so happens that the code you post could compile in straight C.

You might want to look at http://www.gotw.ca/resources/clcm.htm for
the guidelines on posting to comp.lang.c++.moderated to help you
decide what you should or shouldn't post.

Jan 14 '06 #28
I guess then, that my answer is: C is as obselete or out-of-date as Windows
98SE is. Plenty of people still use Windows 98SE, but it's no longer
supported and the latest version is Windows XP which supersedes 98SE. There
are features in XP that 98SE does not have but 98SE did things that XP does
not (er, I can't actually think of one, but I'm sure there is).

But..... This does lead me to another question:

If I am programming using MS Visual C++ .Net Standard 2003, should I be
posting here? If I have a Windows XP issue, I wouldn't post to a Windows
98SE NG just because it may apply.
Jan 14 '06 #29
Lindsay wrote:
I guess then, that my answer is: C is as obselete or out-of-date as Windows
98SE is. Plenty of people still use Windows 98SE, but it's no longer
supported and the latest version is Windows XP which supersedes 98SE. There
are features in XP that 98SE does not have but 98SE did things that XP does
not (er, I can't actually think of one, but I'm sure there is).
Bad analogy. C IS still supported. For reference see the 1999 C standard. When
people write code in C they are choosing not to use those extra "features". A
lot of scientific/numerical programs don't need classes,templates,etc. So the
question is if you don't need/want those features is there any reason to use
C++? C vs. C++ is a personal opinion. Some people like the whizbang features
C++ offers some don't. The key to programming is to use the right tool for the
job that you're comfortable with. That can be C,fortran,C++,java,whatever.

But..... This does lead me to another question:

If I am programming using MS Visual C++ .Net Standard 2003, should I be
posting here? If I have a Windows XP issue, I wouldn't post to a Windows
98SE NG just because it may apply.

You should be posting here if your question pertains to the C++ standard. You
should be posting to a NG like comp.os.ms-windows.programmer if your question is
of the form, "How do I do ... on windows".
Jan 14 '06 #30

"Lindsay" <me@home.com> skrev i meddelandet
news:43**********************@ptn-nntp-reader02.plus.net...
Interesting point. There have been times when I have posted snippets
of code on this NG, only to be told it's not C++. But I'm using MS
C++ .Net Standard to program with, so it must be C++, yes?


It's more a question of style. Some code is obviously C code, even
though it is compilable with a C++ compiler. Compare these simple
snippets:
#include <stdio.h>

int main()
{
printf("Hello world\n");
}

---------------

#include <iostream>
#include <ostream>

int main()
{
std::cout << "Hello world!" << std::endl;
}
Here the second example is defintely C++, while the first one is
arguably a C program.

If you have questions about the finer nuances of the format string
conventions, or how to use some obscure C library function, like
wcscmp(), you have better do that in a C news group. Many C++ coders
just don't care much about those "dark corners", so we can't answer
anyway.
Bo Persson
Jan 14 '06 #31
No, C is not an obsolete language; the linux kernel and the Apple
development tools are two examples of really prominent software written
in C, so it is very much alive :)

Like any language, C has it's strengths and weaknesses, and the
developer has to choose if it's the best tool for the job.

~Jimmy

Lindsay wrote:
I guess then, that my answer is: C is as obselete or out-of-date as Windows
98SE is. Plenty of people still use Windows 98SE, but it's no longer
supported and the latest version is Windows XP which supersedes 98SE. There
are features in XP that 98SE does not have but 98SE did things that XP does
not (er, I can't actually think of one, but I'm sure there is).

But..... This does lead me to another question:

If I am programming using MS Visual C++ .Net Standard 2003, should I be
posting here? If I have a Windows XP issue, I wouldn't post to a Windows
98SE NG just because it may apply.


Jan 14 '06 #32
"Lindsay" <me@home.com> wrote in message
news:43**********************@ptn-nntp-reader02.plus.net
Interesting point. There have been times when I have posted snippets
of code on this NG, only to be told it's not C++. But I'm using MS
C++ .Net Standard to program with, so it must be C++, yes?


The strict test is whether the code conforms to the C++ standard. Since MS's
compiler is not 100% conforming with the C++ standard, it is possible that
something might compile on it without being standard C++.

As a practical matter if you successfully compiled code on MS's C++ compiler
and were told it was C and not C++, then the person claiming that was almost
certainly wrong.

A lot of people have a religious zeal about promoting a programming style
that uses certain code that is only legal in C++ in preference to code that
is legal in both C and C++ (e.g., cout rather than printf). In pursuit of
this goal, they overstate their case by falsely claiming that some
constructs available in both C and C++ are not C++ at all.

I do, however, agree with Bo that if you are using code that is legal in
both languages but involves features of the language that most C++
programmers don't use because they prefer C++-specific alternatives, then
you will often get better advice on comp.lang.c than on comp.lang.c++.

--
John Carson

Jan 14 '06 #33

Lindsay wrote:
....
If I am programming using MS Visual C++ .Net Standard 2003, should I be
posting here? If I have a Windows XP issue, I wouldn't post to a Windows
98SE NG just because it may apply.


You should be aware that Visual C++ has alot of extensions to ISO
C++. These extensions are used heavily in the GUI library and
other Visual C++ libraries, so the typical VC++ uses is pretty
much forced to use them. There are also some minor features
(like no anonymous enums) that seem to be missing from VC++.
So if you have a question about code that's using VC++-specific
features/libraries, it's probably better to ask it in a VC++-specific
group.

Since this is not a moderated group, everyone has to use their
own best judgement about what to post. Someone will always
find a reason to grouse about almost anything you post. I
find it especially funny when people complain about postings
with Indian English grammer or spelling, when there may now
be more C++ programmers in India than any other country.

Jan 14 '06 #34
On 14 Jan 2006 09:04:35 -0800, wk****@yahoo.com wrote:
find it especially funny when people complain about postings
with Indian English grammer or spelling, when there may now
be more C++ programmers in India than any other country.


Oh, you didn't get the memo? They are all writing Java and
Python for Dell... ... in New Delhi of course!

The land that had nourished him and had borne him fruit
now turned against him and called him a fruit. Man, I hate
land like that. -- Jack Handey
Jan 14 '06 #35
wk****@yahoo.com napisal(a):
In my opinion, C is an obsolete language. The only reason to post
anything
to comp.lang.c is to communicate with the many people who don't agree
that
C is an obsolete language.


Not at all. When speed is what matters, C is IMHO preferable over C++.

Jan 14 '06 #36
> When speed is what matters, C is IMHO preferable over C++.

There's hardly a difference if the C++ programmer knows his job,
compiler toolchain withstanding - it's always possibility that the
available C++ compiler is poor compared to the available C compiler,
but that's a different issue from one being debated.

If there is that *toight* loop that is hogging clock cycles in your
program written in C++, you have all the options open for optimization
as in C and some more tricks to keep the code still *readable*,
example: preprocessor macros versus templates. (ofcourse, you can write
really obfuscated code with templates which will make macro spaghetti
look like work of art in comparison :)

If the bottleneck isn't one tight loop or other but architechtural,
then the language doesn't make so big of a difference.

So, what I am interested in.. is.. what is your interesting hypothesis
based on?

Jan 14 '06 #37
I didn't say it was obselete. There was an analogy there, but perhaps you
didn't see it. Point is, this NG is named comp.lang.c++. If I am writing
using a C++ IDE, then shouldn't I use this NG for help?

<js********@gmail.com> wrote in message
news:11*********************@g44g2000cwa.googlegro ups.com...
No, C is not an obsolete language; the linux kernel and the Apple
development tools are two examples of really prominent software written
in C, so it is very much alive :)

Like any language, C has it's strengths and weaknesses, and the
developer has to choose if it's the best tool for the job.

~Jimmy

Lindsay wrote:
I guess then, that my answer is: C is as obselete or out-of-date as
Windows
98SE is. Plenty of people still use Windows 98SE, but it's no longer
supported and the latest version is Windows XP which supersedes 98SE.
There
are features in XP that 98SE does not have but 98SE did things that XP
does
not (er, I can't actually think of one, but I'm sure there is).

But..... This does lead me to another question:

If I am programming using MS Visual C++ .Net Standard 2003, should I be
posting here? If I have a Windows XP issue, I wouldn't post to a Windows
98SE NG just because it may apply.

Jan 14 '06 #38
Ah! Good idea. VC++ NG here I come!

<wk****@yahoo.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...

Lindsay wrote:
...
If I am programming using MS Visual C++ .Net Standard 2003, should I be
posting here? If I have a Windows XP issue, I wouldn't post to a Windows
98SE NG just because it may apply.


You should be aware that Visual C++ has alot of extensions to ISO
C++. These extensions are used heavily in the GUI library and
other Visual C++ libraries, so the typical VC++ uses is pretty
much forced to use them. There are also some minor features
(like no anonymous enums) that seem to be missing from VC++.
So if you have a question about code that's using VC++-specific
features/libraries, it's probably better to ask it in a VC++-specific
group.

Since this is not a moderated group, everyone has to use their
own best judgement about what to post. Someone will always
find a reason to grouse about almost anything you post. I
find it especially funny when people complain about postings
with Indian English grammer or spelling, when there may now
be more C++ programmers in India than any other country.

Jan 14 '06 #39
persenaama wrote:
....
If there is that *toight* loop that is hogging clock cycles in your
program written in C++, you have all the options open for optimization
as in C and some more tricks to keep the code still *readable*,
example: preprocessor macros versus templates. (ofcourse, you can write
really obfuscated code with templates which will make macro spaghetti
look like work of art in comparison :)

....

Why do you believe that there is a speed advantage to using the
preprocessor rather than templates for generic code?

With VC++, l've observed problems where it won't really inline
functions which are declared inline. Did you switch from a
templated inline function or a templated class with inline
functions to macros, and see a speedup?

Jan 14 '06 #40
I can't find an English one!

"Lindsay" <me@home.com> wrote in message
news:43***********************@ptn-nntp-reader04.plus.net...
Ah! Good idea. VC++ NG here I come!

<wk****@yahoo.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...

Lindsay wrote:
...
If I am programming using MS Visual C++ .Net Standard 2003, should I be
posting here? If I have a Windows XP issue, I wouldn't post to a Windows
98SE NG just because it may apply.


You should be aware that Visual C++ has alot of extensions to ISO
C++. These extensions are used heavily in the GUI library and
other Visual C++ libraries, so the typical VC++ uses is pretty
much forced to use them. There are also some minor features
(like no anonymous enums) that seem to be missing from VC++.
So if you have a question about code that's using VC++-specific
features/libraries, it's probably better to ask it in a VC++-specific
group.

Since this is not a moderated group, everyone has to use their
own best judgement about what to post. Someone will always
find a reason to grouse about almost anything you post. I
find it especially funny when people complain about postings
with Indian English grammer or spelling, when there may now
be more C++ programmers in India than any other country.


Jan 15 '06 #41
Lindsay <me@home.com> wrote:
"Lindsay" <me@home.com> wrote:
<wk****@yahoo.com> wrote:
So if you have a question about code that's using VC++-specific
features/libraries, it's probably better to ask it in a
VC++-specific group.
Ah! Good idea. VC++ NG here I come!

I can't find an English one!


I would guess microsoft.public.vc.* are English. Other than those
VC-specific ones, try comp.os.ms-windows.programmer.win32 for
Windows/MFC/etc questions.

Or try the Microsoft news server (see microsoft.com for details, as
I
dont have them handy right now), if you cannot find the MS groups. They
should carry them.

And please, do not top-post and quote properly. Makes reading news
groups a much nicer experience for those reading you posts.

regards
--
jb

(reply address in rot13, unscramble first)
Jan 15 '06 #42
"Lindsay" <me@home.com> wrote in message
news:43**********************@ptn-nntp-reader02.plus.net
I can't find an English one!


microsoft.public.vc.language

Microsoft has a publicly accessible news server

msnews.microsoft.com
--
John Carson
Jan 15 '06 #43
Roman Werpachowski wrote:
wk****@yahoo.com napisal(a):
In my opinion, C is an obsolete language. The only reason to post
anything
to comp.lang.c is to communicate with the many people who don't agree
that
C is an obsolete language.

Not at all. When speed is what matters, C is IMHO preferable over C++.


Now that's arguable. The problem with C++ is that it does a lot of
things implicitly, it's quite easy to overlook the costs of some C++
operations.

C++ programmers who need to write optimized code are (or should be)
aware of the costs of C++ operations, and avoid the costly ones.

There are plenty of examples of C++ programs that are faster than C
programs. Consider std::sort() vs qsort(). Also some C++ containers
(e.g. std::map) would be faster than the equivalent C code based upon
void* and function pointers.

In C++ you can also tune the memory allocation (by writing an allocator)
which makes it much easier to write robust, portable, maintainable and
reusable hacks if you want to. It's not that you can't do it in C, it's
just that it would be no faster and just be more work.

Template metaprogramming is a breakthrough in performance that C just
does not have.

Also bear in mind that C++ compilers have been steadily improving,
whereas C compilers have been mature for much longer.

With C++ is that you can program in a C style when that really is the
best, to optimize the 1% of your code that is taking the time, and write
the rest in normal C++ style.

Calum
Jan 15 '06 #44
>Why do you believe that there is a speed advantage to using the
preprocessor rather than templates for generic code?
I don't believe such a thing, you misread. If you still have trouble
understanding what I wrote after second reading please ask for
clarifications.

With VC++, l've observed problems where it won't really inline
functions which are declared inline. Did you switch from a
templated inline function or a templated class with inline
functions to macros, and see a speedup?


That is VC++ specific behaviour and not topical at clc++ but I can tell
you that there are compiler specific #pragma's to force inlining to
have more depth in case of recursive meta programs (for example) and
you can try __forceinline keyword, which is also compiler specific.

Like I said, optimizations when specific assembly output or similiar
equivalent are required are toolchain and platform specific. Btw. you
can configure most versions of Visual C++ between 6.0 and 2005 to have
different handling of inline keyword to suit your preferences and
tastes better. If you have problems with your compiler and improving
performance of your software feel free to ask specific questions,
hopefully with concrete code and also don't forget to mention which
compiler and target you are using.

To answer your question: No (and no). Explanation: I don't use
preprocessor macros for function inline expansion. Why: because I write
code in a way that it is not so dependent on particular inlining
invoked or not at compilation time. Only the code that is absolutely
performance critical, I do check compiler output and adjust the code to
achieve the desired result. Again, this is compiler and platform
specific and such code and activity is not what I'd discuess in this
particular group.

Jan 15 '06 #45
On 2006-01-14, Bo Persson <bo*@gmb.dk> wrote:

"Lindsay" <me@home.com> skrev i meddelandet
news:43**********************@ptn-nntp-reader02.plus.net...
Interesting point. There have been times when I have posted
snippets of code on this NG, only to be told it's not C++. But
I'm using MS C++ .Net Standard to program with, so it must be
C++, yes?


It's more a question of style. Some code is obviously C code,
even though it is compilable with a C++ compiler. Compare these
simple snippets:


For example, Kernighan & Pike _The Practice of Programming_
contains numerous examples of C code, which were compiled with a
C++ compiler by the authors, to double-check them.

--
Neil Cerutti
Jan 16 '06 #46

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

34
by: yensao | last post by:
Hi, I have a hard time to understand difference and similarities between Relational database model and the Object-Oriented model. Can somebody help me with this? Thank you in advance. ...
21
by: b83503104 | last post by:
Hi, Can someone tell me the difference between single quote and double quote? Thanks
26
by: Frank | last post by:
For my website i would like to display the age of my son in years, months, days and hours. For now i manage to get a result for totals. Like the total number of days. This is the beginning: ...
21
by: Rich | last post by:
I was considering C# for developing a scientific application, but I have noticed a ~30% difference between VC++ .NET and C# on the same machine, under identical conditions: double a = 0,b = 0, c...
4
by: jamesyreid | last post by:
Hi, I'm really sorry to post this as I know it must have been asked countless times before, but I can't find an answer anywhere. Does anyone have a snippet of JavaScript code I could borrow...
3
by: bbawa1 | last post by:
Hi, I have a table which has a field ItemsReceived of type datetime. I have a grid view which has two columns. In first column i have to show the data from field ItemsReceived and in second...
12
by: Petronius | last post by:
Hallo, does anyone have an idea how to implement difference lists in Javascript? Thanks allot in advance
5
by: Julius | last post by:
Hej dudes, I need to calc the difference between two timestamps / dates ... For example what i need to calculate: Date 1: 2007.11.06 - 20:13:04 Date 2: 2007.11.07 - 21:13:04 Difference:...
9
by: viki1967 | last post by:
Hi all! This new forum its great! :) Congratulations !!! My answer: why this my code not working? Nothing error but not work the difference.... : <html>
11
by: cmb3587 | last post by:
I have two arrays and I'm trying to create a 3rd array that is the difference between the two arrays Ex: arrayA: 3 5 8 9 arrayB: 3 4 6 9 difference of A-B: 5 8 however, my...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.