Solved

C and C++ programming

Posted on 1997-11-13
1
201 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
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.

744 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

12 Experts available now in Live!

Get 1:1 Help Now