473,800 Members | 2,586 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Any quick reference for the difference between C and C++

Hi,

I have been using C++ a lot and I've almost forgot what syntax is
support by C and what syntax is support by C++? My feeling is that C++
gives programmer much flexibility. And the code is more localized in
C++ than C, which mean changes won't propogate far away in C++ code. By
reusing through inherence and overloading, a lot of code can be saved.

But I have to use C for some reason. Is there any programming paradigm
in C, which can give me as much advantage that C++ as possilbe? Is
there any quick reference which can tell me what C++ syntax is
forbidden in C?

Best wishes,
Peng

Nov 14 '05 #1
14 1655
Hi, i am new member here.

I am afraid of c++, so i just chose c. my recommendation is
http://www.faqs.org/docs/artu/

--
PS: my 1st post on c.l.c, yay! ;)

Nov 14 '05 #2
"Pe*******@gmai l.com" wrote:

Hi,

I have been using C++ a lot and I've almost forgot what syntax is
support by C and what syntax is support by C++? My feeling is that C++
gives programmer much flexibility.
I don't know who said it but I agree with this statement:

C offers you enough rope to hang yourself. C++ offers a
fully equipped firing squad, a last cigarette and a blindfold.
And the code is more localized in
C++ than C, which mean changes won't propogate far away in C++ code.


I think your jugdements on C here are based on the C code
you have worked on and have little to do with C in general.

Erik
--
+-----------------------------------------------------------+
Erik de Castro Lopo no****@mega-nerd.com (Yes it's valid)
+-----------------------------------------------------------+
"Python addresses true pseudocode's two major failings: that it
isn't standardized, and it isn't executable."
- Grant R. Griffin in comp.dsp
Nov 14 '05 #3
Hmm,both C and C++ are very successful.Choo sing which of them depends
on what you want to do.If you like to do some low-level programming
like me,C is a better choice.And if you like OOP,C++ can be a better
choice.Er,Java is also one of the C-family languages,right ?

Nov 14 '05 #4
<Pe*******@gmai l.com> wrote

I have been using C++ a lot and I've almost forgot what syntax is
support by C and what syntax is support by C++?
new, delete, operator, class, public, private, protected, template,
namespace are C++ keywords.
inline is not C89, but is widely supported. Ditto "//" comments.
references eg void cursor(int &x, int &y) are C++ only.

That's pretty much all you need to know, though run code through a C
compiler if you want to use the common subset.
My feeling is that C++ gives programmer much flexibility.
Yes. There are usually more good approaches to a problem in C++ than in C.
And the code is more localized in C++ than C, which mean changes won't
propogate far away in C++ code. By reusing through inherence and
overloading, a lot of code can be saved.
This is very arguable. By declaring a C file with a few public functions and
a lot of static functions you can have something that is actually more
encapsulated than a C++ class.
But I have to use C for some reason. Is there any programming paradigm
in C, which can give me as much advantage that C++ as possilbe? Is
there any quick reference which can tell me what C++ syntax is
forbidden in C?

There is a difference between programming with objects, and object-oriented
programming. C programs using objects, for instance a structure that is
declared in a file, and with functions that operate on it, are common and
work well. It is possible to do object-orientation in C, where the objects
have relationships with each other, so all our "line" objects have a common
"getlength( ) method. However it normally a mistake because the syntax of
setting up function pointers and nested structures and the like gets so
horrible. That's why C++ was invented

Sometimes people use "object-oriented" as a synonym for "well-designed".
Procedural programs can be just as maintainable and well-structured as
object-oriented ones.
Nov 14 '05 #5
Could you introduce me any information on good C programming style?
Thanks!

Peng

Nov 14 '05 #6
"Pe*******@gmai l.com" wrote:

Could you introduce me any information on good C programming style?


Surely. Just go to my site, download section (URL in organization
header), and look at my C code. It is perfection personified :-)

--
"If you want to post a followup via groups.google.c om, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson

Nov 14 '05 #7
Pe*******@gmail .com wrote:
Could you introduce me any information on good C programming style?
Thanks!


Easy-Peasy:
1. Avoid UB.
2. ???
3. PROFIT!!!

Although a required reading is on the table to get #1 right.
Nov 14 '05 #8
On 4 Jun 2005 21:25:40 -0700, "Pe*******@gmai l.com"
<Pe*******@gmai l.com> wrote:
Is there any quick reference which can tell me what C++ syntax is
forbidden in C?


Well, here's a link :

http://david.tribble.com/text/cdiffs.htm#C++-vs-C

Nov 14 '05 #9
Could you explain these items one by one? Thank!

Nov 14 '05 #10

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

Similar topics

15
2139
by: Ron Adam | last post by:
Does anyone have suggestions on how to improve this further? Cheers, Ron_Adam def getobjs(object, dlist=, lvl=0, maxlevel=1): """ Retrieve a list of sub objects from an object. """
0
9691
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9551
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
10507
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
10036
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...
0
6815
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();...
0
5473
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5607
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4150
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
3765
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.