473,667 Members | 2,798 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4134
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*******@yaho o.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++.m oderated 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.co m 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++.m oderated 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

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

Similar topics

34
7067
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. Yensao
21
3000
by: b83503104 | last post by:
Hi, Can someone tell me the difference between single quote and double quote? Thanks
26
4398
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: starttime = Date.parse("Aug 10,2003, 07:07") sdt = new Date(starttime)
21
2834
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 = 0, d = 0, e = 0; for(int n = 0; n != 6000000; n++) { a = n % 5 *2 / 3 - 4 + 6 / 3 - n + n * 2; b = n * 2.3 - 1 *2 / 3 - 4 + 6 / 3 - n + n * 2; c = n * 3 / 3.5 *2 / 3 - 4 + 6 / 3 - n + n * 2;
4
15730
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 which calculated the difference in years and days between two dates, and takes leap years into account? I'm calculating the difference in the usual way, i.e....
3
4153
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 column I have to show difference between Currenttime and date from ItemReceived. How can I do that.
12
2705
by: Petronius | last post by:
Hallo, does anyone have an idea how to implement difference lists in Javascript? Thanks allot in advance
5
3483
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: 1 day, 1hour
9
2669
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
12106
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 code is just returning me an array of 0's
0
8366
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8888
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8790
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8565
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8650
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6206
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5677
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2779
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2017
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.