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

Answer Posted / kunal kumar

* C does not have any classes or objects. It is
procedure and function driven. There is no concept of access
through objects and structures are the only place where
there is a access through a compacted variable. c++ is
object oriented.


* C structures have a different behaviour compared to
c++ structures. Structures in c do not accept functions as
their parts.


* C input/output is based on library and the processes
are carried out by including functions. C++ i/o is made
through console commands cin and cout.


* C functions do not support overloading. Operator
overloading is a process in which the same function has two
or more different behaviours based on the data input by the
user.


* C does not support new or delete commands. The memory
operations to free or allocate memory in c are carried out
by malloc() and free().


* Undeclared functions in c++ are not allowed. The
function has to have a prototype defined before the main()
before use in c++ although in c the functions can be
declared at the point of use.


* After declaring structures and enumerators in c we
cannot declare the variable for the structure right after
the end of the structure as in c++.


* For an int main() in c++ we may not write a return
statement but the return is mandatory in c if we are using
int main().


* In C++ identifiers are not allowed to contain two or
more consecutive underscores in any position. C identifiers
cannot start with two or more consecutive underscores, but
may contain them in other positions.


* C has a top down approach whereas c++ has a bottom up
approach.


* In c a character constant is automatically elevated to
an integer whereas in c++ this is not the case.


* In c declaring the global variable several times is
allowed but this is not allowed in c++.

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the diamond problem in inheritance?

795


How do you achieve runtime polymorphism?

732


What are the 4 main oop principles?

925


What are oops functions?

771


what are the realtime excercises in C++?

2529


What is basic concept of oop?

875


Which language is pure oop?

736


Question: Implement a base class Appointment and derived classes Onetime, Daily, Weekly, and Monthly. An appointment has a description (for example, “see the dentist”) and a date and time. Write a virtual function occurs_on(int year, int month, int day) that checks whether the appointment occurs on that date. For example, for a monthly appointment, you must check whether the day of the month matches. Then fill a vector of Appointment* with a mixture of appointments. Have the user enter a date and print out all appointments that happen on that date.

895


What is oops concept with example?

750


class CTest { public: void someMethod() { int nCount = 0; cout << "This is some method --> " << nCount; } }; int main() { CTest *pctest; pctest->someMethod(); return 0; } It will executes the someMethod() and displays the value too. how is it possible with our creating memory for the class . i think iam not creating object for the class. Thanks in Advance... Prakash

1941


What is encapsulation in oop?

771


What is the significance of classes in oop?

781


If a=5, b=6, c=7, b+=a%c*2. What is the final value of b?

1087


Can static class have constructor?

762


#include #include #include #include void insert(char *items, int count); int main(void) { char s[255]; printf("Enter a string:"); gets(s); insert(s, strlen(s)); printf("The sorted string is: %s.\n", s); getch(); return 0; } void insert(char *items, int count) { register int a, b; char t; for(a=1; a < count; ++a) { t = items[a]; for(b=a-1; (b >= 0) && (t < items[b]); b--) items[b+1] = items[b]; items[b+1] = t; } } design an algorithm for Insertion Sort

2348