?
Solved

C and C++ programming

Posted on 1997-11-13
1
Medium Priority
?
211 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 5

Accepted Solution

by:
yonat earned 200 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

770 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