This article contains Difference
Between C and C++.
We discuss about difference between C
and C++ according to their features.
Keywords
C has 32 keywords. But C++ has some new keywords such as new and delete.
Length of Identifiers
C has restriction for the length of
identifier. ANSI C recognizes only first 32 character of identifier. ANSI C++
has no limits for length.
Declaration of global variable
In C, a global variable can be declared
several times without using extern keyword. But C++ does not permit this.
Character Constants
In C, character constants are of type
int. But C++ treats character constants as char because compiler has to
distinguish between two overloaded functions.
Example:
void f1(int);
void f2(char);
Programming Paradigm
C supports procedure programming
paradigm. C++ supports object oriented, procedure and generic programming
paradigm.
Function Prototype
It is necessary to provide function
prototype in C++ but it is not necessary in ANSI C.
Reference variable
C++ supports reference variable. But C
does not support reference variable.
Overloading
C++ supports function and operator
overloading but C does not support overloading concept.
Input/Output
C uses functions for input / output,
for example printf and scanf. C++ uses objects for input / output, for example
cin and cout.
OOP Concepts
C does not support OOP concepts like
encapsulation, polymorphism, inheritance etc. C++ is object oriented
programming language, hence it supports OOP concepts.
0 comments:
Post a Comment