Solved

oop

Posted on 1998-03-18
3
192 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
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.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

828 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