Solved

oop in C

Posted on 2004-08-19
9
239 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
 
LVL 9

Expert Comment

by:ankuratvb
ID: 11842285
0
 
LVL 9

Expert Comment

by:ankuratvb
ID: 11842307
0
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
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: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

Suggested Solutions

Title # Comments Views Activity
sameEnds challenge 3 180
Eclipse Neon and jdk 1.8.0 11 267
C Programming - If Statement 8 82
How can I build my own IDE using ASP.NET MVC? 2 54
Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
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…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.

821 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