What are advantages of C++ when comparing with C?

Answers were Sorted based on User's Feedback



What are advantages of C++ when comparing with C?..

Answer / atmiya

1.support data abstraction
2.object oriented programming language
3.support encapsulation of data
4.reusability
5.Inheritance is provide by cpp
6.class & object concept available in cpp
7.polymorphism
8.standard Template library

Is This Answer Correct ?    1 Yes 0 No

What are advantages of C++ when comparing with C?..

Answer / hahahaha

m fedup of these stupid questions

Is This Answer Correct ?    5 Yes 5 No

What are advantages of C++ when comparing with C?..

Answer / guriqbal singh

1: Stronger Type Checking - the use of classes, inheritance
& automatic type

conversions mostly eliminates the need for the abominable
void* of C.



2: Type safe linkage - you can't accidentally call a routine
from another

module with the

wrong type and/or number of arguments - even if your header
files get out of

date.



3: A complex data type is provided. It includes all the
standard arithmetic

operations, implemented as operators, not function calls.



4: User-defined operators and function overloading are
supported. When you

design a data type you can specify which operators &
functions are provided.



5: You can use class libraries to provide robust new data
types which can be

made exceptionally easy to use.

For example, the Rogue Wave 'math.h++' class library
implements general

multi-dimensional arrays which can be manipulated with
high-level operations

and an intuitive syntax:



DComplexArray a(10,10); // Construct a 10x10 complex array

cin >> a; // read it in from standard input

DComplexArray b = inverse(a); // Calculate the inverse

cout << b; // write out the inverse

cout << variance(b.diagonal()); // write out the variance of
the diagonal

elements of b



6: You can define automatic type conversions to convert
between data types.

For example, the Rogue Wave library provides a conversion
from a double array

to a complex array.



DoubleVec a(10, 0.0, 1.0); // Construct a double vector in
initialised to

{0,1,2,3,4...

DComplexVec z = a; // Construct a complex vector initialised to

{(0,0),(1,0),(2,0),...

cout << a; // write them out

cout << z;

cout << cos(z)*exp(DComplex(0,1)*a);



7: Provides inline functions which combine the efficiency of
using macros

with the safety of using functions - simply prepend the word
'inline' in

front of the function - if the compiler can inline it, it will.



inline Double

SumOfPositiveElements

(const DoubleVec&amp; v)

{

Double theSum = 0;

for (int i = 0; i < v.length(); i++) {

if (v[i] > 0) {

theSum += v[i];

}

}

return theSum;

}



8: C++ Compiles most ANSI C code directly and can call
compiled C code

directly, so you don't even have to learn anything new at all!

I recently spent some time converting a copy of SUPER to
ANSI C on a

Macintosh and was able to compile it equally easily with C++
as well. The

C++ version also had the advantage that it worked when I
finished, I had

managed to break the C version so that it crashed almost
immediately.



9: You don't have to put all of your declarations at the top
of each block

in C++. This means

that you can organise your code into logically related
'paragraphs' complete

with their necessary declarations. This makes code much more
maintainable -

you can easily move sections of code around, taking the
necessary

declarations along at the same time. If you use the const
modifier you can

also ensure that variables whose value should not change
after it is first

calculated do not do so.



Double x,y; // Declare two variables

cin >> x >> y; // read in their values

const Double sqrtX = sqrt(x); // Calculate the square roots

const Double sqrtY = sqrt(y);

cout << sqrt(sqrtX+sqrtY);

sqrtX = 42; // Will give an error...



10: Classes provide extensible types, promoting code reuse.
This can

result in major savings in the amount of code written. I saw
a recent

article which stated that the new Taligent operating system,
which is written

in C++, consists of 250,000 lines of code, whereas
WindowsNT, written in C,

was said to consist of 4,000,000 lines of code

Is This Answer Correct ?    0 Yes 0 No

What are advantages of C++ when comparing with C?..

Answer / kapil tyagi

c++ also have the advantage of allowing you to redeclare variables in the midst of code and one line comment...

Is This Answer Correct ?    0 Yes 0 No

What are advantages of C++ when comparing with C?..

Answer / saireddy

compare to c cpp is more security and it deels inheritance, polymorpism,data encapsulation(hiding , binding)which is used real time applications

Is This Answer Correct ?    0 Yes 0 No

What are advantages of C++ when comparing with C?..

Answer / kamlesh

In c++ we can use class,data hiding , abstraction,inheritance,
etc...

c++ is bottom up language.

we can also use message passing.

Is This Answer Correct ?    0 Yes 0 No

What are advantages of C++ when comparing with C?..

Answer / useless

me too got fed up with these questions......... there are no
differences between c and c++ just they are two idiotic ,
Hippocratic useless not understandable nonsense kind of stuffs.

Is This Answer Correct ?    1 Yes 3 No

What are advantages of C++ when comparing with C?..

Answer / secret

you are offered the chance of catching an error :D

Is This Answer Correct ?    10 Yes 18 No

Post New Answer

More C++ General Interview Questions

How is c++ used in the real world?

0 Answers  


What are the general quetions are in DEna bank manager IT/System interviews?

0 Answers   Dena Bank, ICICI,


given unsigned int ui1=3,ui2=7; what are the outputs of a)ui1 & ui2 b)ui1 && ui2 c)ui1 | ui2 d)ui1 || ui2 i also need the justification for the answers thank you

2 Answers  


Is c++ vector a linked list?

0 Answers  


How do you flush a buffer in c++?

0 Answers  






What are static variables?

0 Answers  


Badboy is defined who has ALL the following properties: 1. Does not have a girlfriend and is not married. 2. He is not more than 23 years old. 3. The middle name should be "Singh" 4. The last name should have more than 4 characters. 5. The character 'a' should appear in the last name at least two times. 6. The name of one of his brothers should be "Ram" Write a method: boolean isBadBoy(boolean hasGirlFriend , boolean isMarried, int age , String middleName , String lastName , String[] brotherName); isHaveGirlFriend is true if the person has a girlfriend isMarried is true if the person is married age is the age of the person middleName is the middle name of the person lastName is the last name of the person brotherName is the array of the names of his brothers

1 Answers  


What is the maximum value of a unsigned char a) 255 b) 256 c) 128

0 Answers  


Define whitespace in C++.

0 Answers   HCL,


What is #include math h in c++?

0 Answers  


Explain the purpose of the keyword volatile.

0 Answers  


what is VOID?

0 Answers  


Categories