Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

oop in C

Posted on 2004-08-19
9
Medium Priority
?
256 Views
Last Modified: 2013-12-14

if OOP is possible in C, why was C++ invented, when it could have simply been a third party
library that some company made for 'C'

does c++ do things that are just not possible in 'C' without a writing a large amount
of code, that would not otherwise be required with c++ ?

0
Comment
Question by:apakian
9 Comments
 
LVL 11

Expert Comment

by:Jase-Coder
ID: 11842279
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 11

Expert Comment

by:griessh
ID: 11842938
Hi ankuratvb,

>> third party library
because C++ is a superset of and not just a library. Polymorphism etc are part of the language and not only linkage.

>>c++ do things that are just not possible in 'C'
function overloading is not possible in C, C++ uses a concept called 'name mangling' to differentiate functions.

======
Werner
0
 
LVL 11

Expert Comment

by:griessh
ID: 11842949
sorry, this was for apakian :-)
0
 
LVL 11

Accepted Solution

by:
avizit earned 200 total points
ID: 11843230
to add to it

you can implement classes as structures in C but you really cant have the protection afforded by private and public members etc

0
 
LVL 22

Expert Comment

by:grg99
ID: 11845448
OOP is *possible* in C, but it requires great discipline and many tricky macros.

Perhaps you were misled when you read somewhere that early C++ compilers just translated C++ into C.  That is a non-trivial transformation, not one you'd enjoy doing by hand.

0
 

Expert Comment

by:lebuihung
ID: 11867517
i think there are something we can do easily in c++ but not in c:

1. inheritace.
2. operator overload. For example: operator >> ( ....)

I think those 2 things are very important point of OOP, but C doesnt support or just very fex.

Hope that will help.
0
 
LVL 4

Expert Comment

by:pankajtiwary
ID: 11868118
Actually after C, the next step in the path of OOP was c with classes. It was nothing but a preprocessor sort of stuff which converts a "c with classes" code into a pure C code. It involved introduction of classes and inheritence too if I remember correct. This "c with classes" language was then used to go further and after a lot of efforts, it came out to be C++ what we see today.

The moral of the story is I don't see anything which can be done in C++ and not in C. What it just takes is a lot of investment in terms of time. What C++ provides is a framework for supporting user defined datatypes in exactly the same way it supports built-in types. This make programming more easy and maintainable.

Even you can imlement vrtual functions and inheritance and other stuffs in C but you never want to do so because its no use reinventing the wheel.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
Suggested Courses

886 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question