The main difference between C & C++ is the OOPS (Object Oriented Programming) concept in C++.
This makes C++ much more efficient than C Language. C is procedure oriented language and c++ is object oriented language. But basically it depends on the project to project which language to choose from C or C++.
C language's syntax is very easy as compared to C++.Another Difference is that C uses Top Down approach and focuses on procedures.
In it Data moves as such whereas in C++ uses the bottom up approach and focuses basically on data . There is Data Hiding what we call as data abstraction.
..
Dynamic memory allocation in C is by calloc() and in C++ by malloc() by new and delete respectively. In C we only able to declare the variable in global declaration part, but in C++ it is possible to declare a variable in anywhere in the program.
This is a big advantage of C++ over C because it saves our time while coding. Function prototyping is optional in c whereas it is compulsion in c++.
Sample Syntax for C & C++
C++: -
cout << "Enter two integers";
cin >> v1 >> v2;
C: -
printf("Enter two integers");
scanf("%i %i", &v1, &v2);
In C, we cannot use template and template class. C source code file name should be *.c and *.h for implement file and header file.
Class is not supported in C, so you should convert all of class definition in C++ to structures and functions in C. C++ supports inheritance, polymorphism & encapsulation & C doesn't.
..
Access specifier in C is public, whereas in C++ it is private. C++ has more keywords than C.
Developers:
C: Dennis Ritche in 1972.
C++: Bjrane Stroustrup in 1980s
Jumat, 30 September 2011
C versus C++
09.02 By Candra Dwi Waskito
0 komentar:
Posting Komentar