0% found this document useful (0 votes)
25 views

4.C++ Programming Language

C++ is a statically typed, compiled, general-purpose, object-oriented programming language developed in the early 1980s as a superset of C. C++ supports procedural and object-oriented programming, and adds features like classes, objects, function and operator overloading, namespaces, and strict type checking not present in C.

Uploaded by

Dhananjay
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

4.C++ Programming Language

C++ is a statically typed, compiled, general-purpose, object-oriented programming language developed in the early 1980s as a superset of C. C++ supports procedural and object-oriented programming, and adds features like classes, objects, function and operator overloading, namespaces, and strict type checking not present in C.

Uploaded by

Dhananjay
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

C++ Programming Language

• C++ is a statically typed, compiled, general-purpose, case-sensitive programming language that


supports procedural and object-oriented programming.
[Statically typed languages are the languages like C, C++, Java, etc, In this type of language the data type of a variable is
known at the compile time which means the programmer has to specify the data type of a variable at the time of its
declaration.]
[A compiled language is a programming language that is converted into machine code so that the processor can execute it.
The compiled languages are usually compiled, not interpreted. Example of compiled language –COBOL, C, C++, C#
etc.]
[C++ is used in developing browsers, operating systems, and applications, as well as in-game programming, etc]

• C++ is an Object Oriented Programming language developed by Bjarne Stroustrp at AT & T Bell
Laboratories, USA in the early 1980’s.
• C++ is nothing but C language extended or improved with the concept of Classes and Objects.
Hence every valid C program is also a C++ program.
• C++ is called as a superset of C programming language.
• The major design creation of C++ was to retain its compatibility with C programming language.
• All valid C programs are valid C++ program. Hence a C++ compiler can compile and execute all
valid C programs but reverse is not true.
• The C++ language uses most of the C language features like decision making statements, looping
statements, structure etc.
• Apart from supporting the keywords of C language, C++ also adds certain additional keywords
which help implementing object oriented paradigm.

Difference between C and C++ programming language.


Sr. C C++
No
1. C was developed by Dennis Ritchie C++ was developed by Bjarne Stroustrup in the
between the year 1969 and 1973 at early 1980’s
AT&T Bell Labs.
2. C is procedural Oriented C++ is an Object Oriented Programming
Programming language, which more language which more emphasis is on data rather
emphasis is on procedure (function) than procedure.
rather than data.
3. Concept of “default argument “is not Concept of “default argument” is available in
available in C Programming C++ Programming language.
language.
4. Declarations of variables have to be Declarations of variables can be done at any
done before the first executable point in the program, wherever necessary;
statement within a block making the making variable declarations more flexible
declaration of variables very rigid. compared to C programming language.
5. There is no strict type checking in C Strict type checking in done in C++. So many
programming language. programs that run well in C compiler will result
in many warnings and errors under C++
compiler.
6. Function and operator overloading is Function and operator overloading is supported
not supported in C. by C++.
7. Functions in C are not defined inside Functions can be used inside a structure in C++.
structures.
8. Namespace features are not present Namespace is used by C++, which avoid name
inside the C. collisions.
9. C does not have access specifier. C++ has access specifier i.e public, private and
protected access specifier.
10. C programming language supports C++ supports both early binding as well as late
only early binding. binding.
11. By default return type of any function By default return type of any function in C++
in C programming language is programming language is “int”.
“void”.
12. The memory allocation and de- The memory allocation and de-allocation is
allocation is done by the built in done easily using the “new” and “delete”
function i.e malloc(), operators.
calloc(),realloc() and free().
13. It follows the top-down approach in It follows the bottom - up approach in program
program design. design.

Strict Type checking


C++ is a strongly typed language and it uses strict type checking.

Strict type checking means function prototype must be known for each function which is
called and the call function must match the function prototype.

The function prototype specify function name and number of arguments passed and the return
type ( if any) of the function.

Eg:
void max(int,int);
int max(int,int);
void max();
In C++, function prototyping is compulsory; if the function declaration is not placed before the
function call it will raise error where as in C programming language it is optional.

Eg:

Compilation of the above program produces the following errors:


C++ checks all the parameters passed to a function against its prototype declaration during
compilation. It produces errors if there is a mismatch in its argument type and this can be overcome
by placing the prototype of the function max() before main() function.
The advantage of strict type checking is that the compiler warns the users if a function is called
with improper data types. It helps the user to identify errors in a function call and increase the
reliability of a program.

You might also like