Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

oop in C

Posted on 2004-08-19
9
Medium Priority
?
251 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.

688 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