what is the main difference between c and c++?

Answer Posted / rohit

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
operator overloading.


by:- ROHIT AGGARWAL
PUNJAB

Is This Answer Correct ?    191 Yes 35 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is abstraction example?

616


What is Difference Between Inheritance and creating object and getting data? means Class A extends B{ B.getMethod();} (OR) Class A{ b obj=new B(); obj.getMethod(); }

1981


They started with the brief introduction followed by few basic C++ questions on polumorphism, inheritance and then virtual functions. What is polymorphims? How you will access polymorphic functions in C? How virtual function mechanism works?

1393


i am getting an of the type can not convert int to int *. to overcome this problem what we should do?

1833


explain sub-type and sub class? atleast u have differ it into 4 points?

1830






What is the real time example of encapsulation?

595


What is solid in oops?

600


What is object in oop with example?

697


What is encapsulation in ict?

606


How can you overcome the diamond problem in inheritance?

765


Whats oop mean?

588


Why multiple inheritance is not allowed?

581


I have One image (means a group photo ) how to split the faces only from the image?............ please send the answer nagadurgaraju@gmail.com thanks in advace...

1622


What is overloading in oops?

596


What are different types of JVM's? for example we use dalvik jvm for android then what about the remaining operating systems?

1650