Solved

C and C++ programming

Posted on 1997-11-13
1
204 Views
Last Modified: 2010-04-10
I am new user of C++ programming. How the C are differ from C++ program. I hope it will be specify in following aspects;
filename, program structure, data type, function, expression, control structure and operator.
0
Comment
Question by:feda
1 Comment
 
LVL 5

Accepted Solution

by:
yonat earned 100 total points
ID: 1173144
C++ includes most of C. It adds two major features, and several minor enhancements. The two major additions are:
1. Support for object oriented programming (classes and virtual functions).
2. Support for generic programming (templates).
Other enhancements include exception handling (which has been also added to C9x), stronger typing, inline functions, namespaces, standard specification of linkage (eg extern "C") etc.
The C++ standard library includes the C standard library, and adds much more, including the iostream library and STL.

About the aspects you mentioned:
1. Filename - no difference. In both C and C++ the filenames depend on the underlying operating system.

2. Program structure - C supports structured programming (separating the program to functions), while C++ supports also object oriented programming (separating the program to classes and objects) and generic programming (separating the program to templates).

3. Data type - the basic types are the same: int, char etc. However, in C++ you can define new types (classes) that behave like built-in types. In C, you can only define "dumb" structs.

4. Function - both languages support functions in the same way. C++ adds inline function support.

5. Expression - the expression syntax is the same in both languages.

6. Control structure - Both languages have the same control structures. There is only a slight difference in the usage of "for".

7. Operator - Both languages have the same operators. However, C++ allows you to define operators for your own types (classes), and make them behave as-if they were built-in types. For example, you can define a class Complex, and define operators +, - and * for it.
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now