Solved

oop

Posted on 1998-03-18
3
189 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
Comment Utility
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
Comment Utility
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
Comment Utility
Thank you yonat for your comments. Pl keep in touch.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
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 opening and reading files in the C programming language.

763 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

10 Experts available now in Live!

Get 1:1 Help Now