Free Web Hosting by Netfirms
Web Hosting by Netfirms | Free Domain Names by Netfirms


michaellim.netfirms.com
 

'Life is short, enjoy life.'

Michael Lim

Main Menu

Home

My languages

My programs

My notes

My resume

My pictures

My readings

My work experience

Links

Schedules

My guestbook

 

 

TRANSLATION CENTER by Google

Translate text from               

Translate my homepage text from       

 

Differences between C & C++.

The main difference between C and C++ is that C isn't object-oriented. Okay---that doesn't actually tell you what you want to know; here are some details:


+ structs don't copy in C. That is, if a and b are structs then the line a = b; doesn't work. Nor will structs be fed into functions as arguments. The only way to deal with them sensibly is to use pointers to them, or to write functions to copy their elements explicitly. classes (with private members) don't exist in C.

+ There is no operator and function overloading in C. If a function has a name, then that's it---you can't have another version with the same name that does the same thing with different arguments, as you can in C++. The fact that << and >> (left and right shift) do output and input in C++ is a consequence of the ability of the language to overload those operators. Output and input in C are handled by functions called printf and scanf respectively (these also work in C++ if you want, of course).

+ In C storage allocation and de-allocation are not handled by new and delete but by a function called malloc. In general, the whole process is a bit more messy in C, but is not too bad once you get the hang of it.

There are many more detailed differences, of course---see the books on the two languages for information on those. In general, C++ is neater and easier to read than C, and it does not compile to less efficient code as long as you know what you are doing. An example inefficiency here would be sending a large struct or class as a function argument by copying, as opposed to by reference using const X& fred (or whatever). The copying will eat stack space and waste time.

The only real reason for using C in preference to C++ is that the machine on which you wish to compile your program doesn't have a C++ compiler.

Quotes!

"In order to live skilfully, in harmony with the dynamic Universe, it is essential to accept the reality of change and impermanence. The wise person therefore travels lightly, with a minimum of clutter, maintaining the proverbial 'open mind' in all situations, for he or she knows that tomorrow's reality will not be the same as today's. He or she will also have learnt the divine art of letting go - which means not being attached to people and possessions and situations, but rather, when the time for parting comes, allowing that to happen graciously." The elements of buddhism - John Snelling.

"Humans are just shadows and dust! (Gladiator) It doesn't matter where you are from, you are no different from the person borned on the other side of the world. That's why you have social science classes, to study how humans behave. It's just logic, nothing more or less than a computer." Michael Lim.

"Life in every breath. Great men rised and fell. Does it matter to be one?" The Last Samurai.

"God is jealous of us because we are immortal and every moment of our life is precious." Troy.

 

Google
 

Copyright michaellim.netfirms.com.