what is the main difference between c and c++?
Answer Posted / adil siddiqui
1.C is a structured programming language while C++ is an
object programming language .
2.c++ support operator overloading but c doesn't support
operator overloading
3. C employs top down approach, but c++ employes buttom up
approach.
4.C give emphasis in algorithims and functions, but C++
give emphasis on the data and objects.
5.In C we are using #include<stdio.h> as header file, but
in C++ we are using #include<iostream.h> as header file.
6.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.
7. *Inline functions are not available in C.
8.The I/O functions are entirely different in C and C++
(ex: printf( ), scanf( ) etc. are part of the C language).
9.Structures in C cannot have functions
10.You cannot overload a function in C (i.e. you cannot
have 2 functions with the same name in C).
11.C does not have reference variables (in C++
referencevariables are used in functions).
12.In other worlds C is used more with hardware while C++
is used more with software, mainly because of more
abstraction and features in C++.
13.You have to include the struct keyword before the name
of the struct type to declare a struct: In C++, you could
do this, and have a new instance of a_struct called
struct_instance. In C, however, we have to include the
struct keyword when declaring struct_instance
14.C++ has a much larger library than C, and some things
may be automatically linked in by C++ when they are not
with C.
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
What is object-oriented programming? Webopedia definition
What is object in oops?
How do you achieve runtime polymorphism?
What do you mean by variable?
Question In a class, there is a reference or pointer of an object of another class embedded, and the memory is either allocated or assigned to the new object created for this class. In the constructor, parameters are passed to initialize the data members and the embedded object reference to get inialized. What measures or design change should be advised for proper destruction and avioding memory leaks, getting pointers dangling for the embedded object memory allocation? Please suggest. Question Submitted By :: Sunil Kumar I also faced this Question!! Rank Answer Posted By Re: In a class, there is a reference or pointer of an object of another class embedded, and the memory is either allocated or assigned to the new object created for this class. In the constructor, parameters are passed to initialize the data members and the embedded object reference to get inialized. What measures or design change should be advised for proper destruction and avioding memory leaks, getting pointers dangling for the embedded object memory allocation? Please suggest. Answer # 1 use copy constructors 0 Shanthila There is something to be taken care in destructor, in copy constructor, suppose the memory is assigned to the embedded member object pointer with the parameter passed value, but if some other objects of different class also are pointing to this memory, then if some one deletes the object then this class member pointer object will become dangling, or if the object is not deleted properly then there will be memory leak. Please suggest the design change required to handle or avoid this situation
What is the purpose of polymorphism?
What are oops functions?
hi, this is raju,iam studying b.tech 2nd year,iam want know about group1 and group2 details, and we can studying without going to any instutions? please help me.
Plese get me a perfect C++ program for railway/airway reservation with all details.
What is coupling in oops?
What is inheritance in simple words?
What is encapsulation selenium?
What is balance factor?
Why we use classes in oop?
Can static class have constructor?