Thread: Help me to understand Object Oriented in C.

  1. #1
    Registered User
    Join Date
    Jan 2012
    Posts
    3

    Question Help me to understand Object Oriented in C.

    Hi. I'm new here. Sorry if there is somehow a thread like this, but i didn't find it. Whaterver, I'd love to understand and know how to implement OO in C language.

    I tried to read this (http://www.cs.rit.edu/~ats/books/ooc.pdf) but I dont got it very well. It seems to start in a very confusing way talking about Sets and whaterver.

    Help me please
    Can you give me an example, tutorial, whatever simpler to understand?

    ---
    Sorry if bad english.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    What is object oriented programming to you?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Jan 2012
    Posts
    3
    a programming's method/approach. I have no problem to understand OO, just in how to apply it in pure C (not C++).
    Last edited by Teehee; 01-24-2012 at 11:36 AM.

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    What's so special about this "programming method/approach" that you want to "implement OO in C"?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    I believe laserlight wanted a little more detail than that.
    The cost of software maintenance increases with the square of the programmer's creativity. - Robert D. Bliss

  6. #6
    Registered User
    Join Date
    Jan 2012
    Posts
    3
    I just would like to programming in C using an OOP approach. Like here (http://x86asm.net/articles/oop-from-...ive/index.html), that show me how to implement from assembly level. But combining this structure with the first link i put, i got confused.
    Last edited by Teehee; 01-24-2012 at 11:47 AM.

  7. #7
    Registered User
    Join Date
    Jan 2009
    Posts
    1,485
    So you want someone here to read the 200 page document and then explain it to you? Did you read the preface?

    "I had fun discovering that ANSI-C is a full-scale object-oriented language. To share this fun you need to be reasonably fluent in ANSI-C to begin with — feeling comfortable with structures, pointers, prototypes, and function pointers is a must."

  8. #8
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    Another quote from the book so people understand what this is about:
    The first six chapters develop the foundations of object-oriented programming with ANSI-C. We start with a careful information hiding technique for abstract data types, add generic functions based on dynamic linkage and inherit code by judicious lengthening of structures. Finally, we put it all together in a class hierarchy that makes code much easier to maintain.
    The cost of software maintenance increases with the square of the programmer's creativity. - Robert D. Bliss

  9. #9
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by Teehee
    I just would like to programming in C using an OOP approach.
    Well, two of the most common concepts of OOP is abstraction and encapsulation. The material that you read starts off with a Set abstract data type that encapsulates an integral set member id. Yet you say that the article "seems to start in a very confusing way talking about Sets and whaterver". Is that because you do not know very much of C, as Subsonics suspects, or because you actually do not know very much of OOP, or were you simply too intimidated by the article to read it carefully when it is actually within your understanding?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  10. #10
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    Why don't you learn OO programming using a proper OO language like C++ first, so you actually understand the underlying concepts.

    Then later worry about all the hacks and compromises it takes to make OO work in C (which I suspect is what's really confusing you).

    On the other hand, why are you worrying about it in the first place?
    That paper is 20 years old, when some of the motivations for doing such a thing (C++ compilers weren't very good) were still relevant.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  11. #11
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    Quote Originally Posted by Salem View Post
    That paper is 20 years old
    Exactly, it's really of historical interest only. The first C++ "compiler" actually produced C code, so I suppose if someone were interested, this paper would give the details of how that was done. For a beginner it would probably do more harm than good.
    The cost of software maintenance increases with the square of the programmer's creativity. - Robert D. Bliss

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Object Oriented C
    By CSaw in forum C Programming
    Replies: 6
    Last Post: 07-06-2011, 05:06 AM
  2. Object oriented SDL
    By jamort in forum Game Programming
    Replies: 3
    Last Post: 01-31-2011, 09:07 AM
  3. Need some help with C++ object oriented programing
    By akairyuu in forum C++ Programming
    Replies: 2
    Last Post: 09-26-2009, 02:30 AM
  4. new to object oriented!!!!
    By salmanriaz in forum C++ Programming
    Replies: 2
    Last Post: 03-12-2009, 07:43 AM
  5. object oriented C
    By FlatLost in forum C Programming
    Replies: 4
    Last Post: 11-08-2005, 06:22 AM