0 Bewertungen0% fanden dieses Dokument nützlich (0 Abstimmungen)
64 Ansichten3 Seiten
C++ is an object oriented programming language which eliminate some pitfall of conventional or procedural programming language. C++ includes everything present In C but the use of some c features is deprecated in C++.
C++ is an object oriented programming language which eliminate some pitfall of conventional or procedural programming language. C++ includes everything present In C but the use of some c features is deprecated in C++.
Copyright:
Attribution Non-Commercial (BY-NC)
Verfügbare Formate
Als DOC, PDF, TXT herunterladen oder online auf Scribd lesen
C++ is an object oriented programming language which eliminate some pitfall of conventional or procedural programming language. C++ includes everything present In C but the use of some c features is deprecated in C++.
Copyright:
Attribution Non-Commercial (BY-NC)
Verfügbare Formate
Als DOC, PDF, TXT herunterladen oder online auf Scribd lesen
Actually c is a procedural programming language which
cann't face the real world problem. It has some drawback
like a global data is shared by all function and if in a large program it is find out difficult that which function uses which data.
On the other hand c++ is an object oriented programming
language which eliminate some pitfall of conventional or procedural programming language. It is a concept or approach for designing a new software. It is nothing to do with any programming language although a programming language which support the oops concept to make it easier to implement.
This is the main different between c and c++.
In object oriented programming, the programmer can solve problems by breaking them down into real-life objects (it presented the programmer with an opportunity to mirror real life). What is an object? This topic is dealt with extensively in the chapter on ‘Objects and Classes’ but a brief introduction is provided here.
Consider the category of cars. All cars have some common
features (for example all cars have four wheels, an engine, some body colour, seats etc.). Are all cars the same? Of course not. A Fiat and a Ford aren’t the same but they are called as cars in general. In this example cars will form a class and Ford (or Fiat) will be an object.
For those people who know C programming, it would be useful
to know the differences between C and C++. Basically C++ includes everything present in C but the use of some C features is deprecated in C++.
*C does not have classes and objects (C does not support
OOP) *Structures in C cannot have functions. *C does not have namespaces (namespaces are used to avoid name collisions). *The I/O functions are entirely different in C and C++ (ex: printf( ), scanf( ) etc. are part of the C language). *You cannot overload a function in C (i.e. you cannot have 2 functions with the same name in C). *Better dynamic memory management operators are available in C++. *C does not have reference variables (in C++ reference variables are used in functions). *In C constants are defined as macros (in C++ we can make use of ‘const’ to declare a constant). *Inline functions are not available in C. In C memory allocation is done with malloc statement whereas in C++ it is done through new keyword.Also memory is deallocated in C using free statement while in C++ deallocation takes place through delete. C is a procedural Language, but C++ is a object oriented language.
* C employs top down approach, but c++ employes buttom up
approach.
* Here in C, when ever we are writing a program, the data
are not secured from the outside world. but in C++ data are secured from the outside world.
* C give emphasis in algorithims and functions, but C++
give emphasis on the data and objects.
* In C we are using #include<stdio.h> as header file, but
in C++ we are using #include<iostream.h> as header file. DIFFERENCE b/w C and C++ 1.) C was the C++ predecessor. As its name implies, alot of C remains in C++. Although not actually being more powerful than C, C++ allows the programmer to more easily manage and operate with Objects, using an OOP (Object Oriented Programming) concept.
2.) C++ allows the programmer to create classes, which are
somewhat similar to C structures. However, to a class can be assigned methods, functions associated to it, of various prototypes, which can access and operate within the class, somewhat like C functions often operate on a supplied handler pointer.
3.) Although it is possible to implement anything which C++
could implement in C, C++ aids to standardize a way in which objects are created and managed, whereas the C programmer who implements the same system has alot of liberty on how to actually implement the internals, and style among programmers will vary alot on the design choices made.
4.) In C, some will prefer the handler-type, where a main
function initializes a handler, and that handler can be supplied to other functions of the library as an object to operate on/through. Others will even want to have that handler link all the related function pointers within it which then must be called using a convention closer to C++.
5.) In C, there's only one major memory allocation function:
malloc. You use it to allocate both single elements and arrays. In C++, however, memory allocation for arrays is somewhat different than for single objects; you use the new[] operator, and you must match calls to new[] with calls to delete[] (rather than to delete).
6.) C++ applications are generally slower at runtime, and
are much slower to compile than C programs. The low-level infrastructure for C++ binary execution is also larger. For these reasons C is always commonly used even if C++ has alot of popularity, and will probably continue to be used in projects where size and speed are primary concerns, and portable code still required (assembly would be unsuitable then).
7.) In C++, you are free to leave off the statement 'return 0;' at the end of main; it will be provided automatically but in C, you must manually add it.
8.) A function can be declared in C as int fun( );. This
means that fun( ) is a function without any argument or any number of arguments. But in C++, this means that the function with no argument at all.
9.) C++ support operator overloading but c doesn't support