Solved

oop in C

Posted on 2004-08-19
9
246 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
Industry Leaders: 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!

 
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 100 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
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…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

628 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