Solved

oop

Posted on 1998-03-18
3
190 Views
Last Modified: 2013-12-14
Is c object oriented language or not? Can struct replace class? (I've used functions inside structures and it works)
0
Comment
Question by:jas_jan
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
yonat earned 50 total points
ID: 1257760
C is not an object oriented language. It takes great effort and pain to implement object oriented designs in C (beleive me, I have done this).

A C struct cannot replace a C++ class. You will have to implement a complete virtual table mechanism in order to have anything close to polymorphism. Even then, you don't get access protection, and the whole thing is very difficult to write and maintain.

My recomendation: For object oriented programming, use an object oriented language (C++ or some other OOPL). It will make your life easier.
0
 

Author Comment

by:jas_jan
ID: 1257761
Yes, you can define objects in C. You can even do it in assembly language. To say that it requires "some extra effort" is a big understatement. It is *painful*. Not only for the programmer defining the objects, but also for the programmers using these object, and for the programmers who need to extend these objects.

C *enables* you to do anything, including objects. However, it does not *support* object oriented programming. OOPLs are languages that wither support (like C++) or enforce (like SmallTalk) OOP. So C isn't an OOPL.

BTW, I remember Apple had an OO library using C for QuickDraw GX. If you're interested, here's the URL: http://devworld.apple.com/ngs/lpp/adrpub/docs/dev/techsupport/insidemac/GXOverview/GXOverview-2.html
0
 
LVL 5

Expert Comment

by:yonat
ID: 1257762
Thank you yonat for your comments. Pl keep in touch.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand columnThat will then direct you to their download page.From that page s…
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 recursion in the C programming language.

911 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now