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

Answer Posted / sumit gupta , bangalore

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.

Is This Answer Correct ?    1710 Yes 235 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is abstraction oop?

621


Why multiple inheritance is not allowed?

581


Hi friends I have experience of 6 months in website design and maintanence. Now i am looking for other IT jobs.. to switch platform. please post any interview you know in chennai.

1780


How do you answer polymorphism?

577


Why is object oriented programming so hard?

612






What polymorphism means?

619


What are the 3 pillars of oop?

611


Can an interface inherit a class?

557


any one please tell me the purpose of operator overloading

1965


Why is oop useful?

600


write a programe to calculate the simple intrest and compund intrest using by function overlading

1666


What is abstraction in oops?

581


What is encapsulation with real life example?

566


Prepare me a program for the animation of train

1994


What are the three main types of variables?

600