What's the different between C and C++?


 
Thread Tools Search this Thread
Top Forums Programming What's the different between C and C++?
# 1  
Old 04-19-2003
Question What's the different between C and C++?

Since I am a bad student (always sleep in class), I don't quite remember how my professor talked about the differences between Object-oriented programming and Structured (or procedual) programming.

What I understand is it:

Structured programming combines a series interacting functions without consider the data, in other words, the data is considered a passive quantity to be acted upon by constrol structures and functions.

The Object-oriented programming uses data abstraction, inheritance, and dynamic binding to construct programs.


Actually when people start studying C++, they will learn Input/Output, if, while loop, ect., right? I think those are kind of structured programming. So I guess the differences between C and C++ must be somewhere in how to use Class, Struct, or Union??

I admit I don't know how C exactly works (Our school doesn't teach C). And I don't know why people always says "C isn't an object-oriented" (I shouldn't sleep in class anymore...........let's take it to the library ). So, could someone explain it to me a little bit?

Thanx.
# 2  
Old 04-24-2003
Asleep in your lessons? You deserve to fail!

But this once I will give you a clue...

Firstly, Object Orientation is a design philosophy which is not necessarily associated with a specific language. It is, if you will, a way of thinking about your programming problems and how to solve them.

In my experience my better designs have tended towards OO anyway. The four main principles behind OO are: abstraction,encapsulation, inheritance and polymorphism.

It is possible to take a language like C or Pascal and implement a solution with some or all of those properties. The languages do not lend themselves to that use and you would have to work harder programmatically.

Languages like C++ and Java are intended to be used within an OO framework and therefore support features for OO. Although these languages can be used in such a way that will break OO principles.

To say 'C isn't object orientated' is sort of correct, but misses the point somewhat. It is more accurate to say 'C does not support object orientated features'.

Ultimately you will still need to encode a sequence of tasks for the computer to execute Procedural Programming and OO are just 2 different ways of approaching that problem and both have their merits and disadvantages.

Remember , its not the methodology which gives success; its the thinking (or design) and the discipline of the designer/programmer which does. (Plus thorough testing!)

My advice to you, now, is to go off and read up on this stuff; drink plenty of coffee; practice your design and programming!

MBB
# 3  
Old 04-24-2003
Just building on to what mbb said...

The way I always thought of it is that procedural programming contains the instructions to do everything you want to do, contained within your one program. If there's something really basic that you want to do in every program you create, you have to include the code again and again and again in each program you create.

Object-oriented programming allows you to create a separate file - an object - with the code necessary to do some basic task. Each program you create in the future can call that object .. you don't even need to know what the code looks like inside the object anymore. You just need to know what data it accepts and what data it will return to you.

This allows joe blow to create an object and share it with all his friends as long as he tells them what kind of data the object expects and what kind of data the object will return.

Take a look at this page.
# 4  
Old 05-18-2003
ok,just it!

Thank you!
# 5  
Old 06-06-2003
About your problem

To add to what mbb said, it is good for you to know this: C++ is only in a 30% object-oriented supportive, since it is a hubrid language and superset of C.
Try to find about C++ in :www.chris-lott.org/resources/cstyle or
www.possibility.com/Cpp/CppCodingStandard.html
also there are the news groups: comp.lang.C++ and comp.lang.c++.moderate

A warning, it will be difficult for you to learn C++ without first, at least program in C. However, if you have the tools, books and the will to try you wan't regret it.

Have fun!Smilie
# 6  
Old 06-06-2003
Question

One little question (i don't understand)
if 'C++' is more powerful, more flexible then 'C',
why some people still use C - language?
What is it: legacy interface or time-critical tasks?
# 7  
Old 06-09-2003
Becuase well written C compiles into some of the fastest binaries around.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

What are the differences between 'bash' and 'sh'

Hopefully this doesn't come off as too much of a "newbie" question or a flamebait. But I have recently begun working with a Sun Solaris box after having spent the past five years working with RedHat. From what i can tell, thing look fairly similar and the 'man' command is some help. But I've... (7 Replies)
Discussion started by: deckard
7 Replies

2. UNIX for Advanced & Expert Users

How to remove a file with a leading dash '-' in it's name?

Somehow someone created a file named '-ov' in the root directory. Given the name, the how was probably the result of some cpio command they bozo'ed. I've tried a number of different ways to get rid of it using * and ? wildcards, '\' escape patterns etc.. They all fail with " illegal option --... (3 Replies)
Discussion started by: GSalisbury
3 Replies

3. Email Antispam Techniques and Email Filtering

Procmail recipe: blocking 'unsubscribe and opt-out' messages....

Here is a crude procmail recipe that I quickly created (NOT a procmail recipe expert, btw) that has been catching lots of spam (current second after the charset_spam recipe posted earlier): :0B * .*If.you.do.not.wish.to.receive...* more_spam :0B * You.requested.to.receive.this.mailing... (0 Replies)
Discussion started by: Neo
0 Replies

4. UNIX for Dummies Questions & Answers

quoting echo 'it's friday'

echo 'it's friday' why appear the > (3 Replies)
Discussion started by: yls177
3 Replies

5. UNIX for Dummies Questions & Answers

HELP! The '/var/adm/message' file increase every few seconds???

Hi, guys, I have a big problem. I've got a sun solaris 4.1.4 workstation, and the /var/adm/message file will add one row every few seconds. It becomes a large file in a short time. I wander if there are some mistakes configuring the workstation. the /var/adm/message is as follow: ... (3 Replies)
Discussion started by: cloudsmell
3 Replies

6. Filesystems, Disks and Memory

HELP! The '/var/adm/message' file increase every few seconds???

Hi, guys, I have a big problem. I've got a sun solaris 4.1.4 workstation, and the /var/adm/message file will add one row every few seconds. It soon becomes a large file. I wander if there are some mistakes configuring the workstation. the /var/adm/message is as follow: ... (1 Reply)
Discussion started by: cloudsmell
1 Replies

7. UNIX for Advanced & Expert Users

Terminal 'Local Echo' lost on Modem Dial-out

Can anybody help me? I am developing a utility for automating message paging to a BT alphanumeric pager. I am using a USR 56K Fax-modem connected to /dev/cuab on a Sun Ultra-10. I am using the UNIX 'tip' utility to connect to the modem and I have configured the modem as follows: Baud Rate:... (2 Replies)
Discussion started by: mybeat
2 Replies

8. Shell Programming and Scripting

Clearify what it means under 'WHAT' when hit the 'w'-command

I wonder how I shall read the result below, especially 'what' shown below. The result was shown when I entered 'w'. E.g what is TOP? What is gosh ( what does selmgr mean?)? login@ idle JCPU PCPU what 6:15am 7:04 39 39 TOP 6:34am 6:45 45 45 TOP 6:41am ... (1 Reply)
Discussion started by: Aelgen
1 Replies

9. Programming

i can't use 'make' in my computer?

I need to compile a file,but 'make' does not work.please tell me how to use it or need which tools? (3 Replies)
Discussion started by: dsun5
3 Replies

10. UNIX for Dummies Questions & Answers

How to subtract 2 hours from 'date' in shell ( /bin/sh ) script ?

I write a sh script that zip and copy to tape all files that older then 2 hours. 1. The way I choose is - touch a file with "now - 2 hours", then use fine with '! -newer' 2. Do you have any other idea to do it ? tnx. (1 Reply)
Discussion started by: yairon
1 Replies
Login or Register to Ask a Question