CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 28

Thread: oop with c?

  1. #1
    Join Date
    May 2005
    Posts
    50

    oop with c?

    hi,
    i heared it's possible to use oop in C.
    does someone can give me a brief introduction of how it is being done?

    thanks in advance

  2. #2
    Ejaz's Avatar
    Ejaz is offline Elite Member Power Poster
    Join Date
    Jul 2002
    Location
    Lahore, Pakistan
    Posts
    4,211

  3. #3
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,150

    Re: oop with c?

    May I ask why you want to mimick OOP in C instead of using C++?
    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

  4. #4
    Join Date
    Aug 2002
    Location
    Cluj-Napoca,Romania
    Posts
    3,496

    Re: oop with c?

    Quote Originally Posted by Marc G
    May I ask why you want to mimick OOP in C instead of using C++?
    Maybe just for fun.

    They have a show on Discovery Channel, I think it is called "Lost secrets of the Ancient World" or something like that. In that show a bunch of guys have to build bridges, cranes, ships etc using only ancient materials, technologies and tools. ( not that C is ancient or anything)
    Har Har

  5. #5
    Join Date
    Oct 2005
    Location
    Bangalore
    Posts
    1,051

    Re: oop with c?

    Quote Originally Posted by SunCore
    hi,
    use oop in C.
    try Object oriented Programming in c ul get all the stuff that u need....

    n also found This

    You should read this paper on OO in ansi C

    regards
    - Sreehari
    "Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us."
    " Everybody is sent to Earth on a purpose. I am so Lagging behind that i won't die." – Calvin

  6. #6
    Join Date
    Jun 2002
    Location
    Moscow, Russia.
    Posts
    2,176

    Re: oop with c?

    There is another point: if you by some circumstances need to program in C, it's generally better to use OOP style.
    "Programs must be written for people to read, and only incidentally for machines to execute."

  7. #7
    Join Date
    Aug 2002
    Location
    Cluj-Napoca,Romania
    Posts
    3,496

    Re: oop with c?

    Quote Originally Posted by RoboTact
    There is another point: if you by some circumstances need to program in C, it's generally better to use OOP style.
    Why?
    Har Har

  8. #8
    Join Date
    Oct 2000
    Location
    London, England
    Posts
    4,773

    Re: oop with c?

    You use lots of structs, construct with Create() functions and destroy with Destroy() functions.

    Polymorphism is achieved with pointers to functions.

  9. #9
    Join Date
    Aug 2002
    Location
    Cluj-Napoca,Romania
    Posts
    3,496

    Re: oop with c?

    It is possible to simulate OOP in C but I'm not sure if it is worth it. If the decission to use C and not C++ was correct it means that you do not need an OOP approach and that you are aiming for something else. In that case why use OOP?

    This is a more generic question actually: why force OOP on languages not designed for it? ASM, Visual Basic etc are fine languages for the tasks they were designed to. OOP is not among those tasks.
    Har Har

  10. #10
    Join Date
    Oct 2000
    Location
    London, England
    Posts
    4,773

    Re: oop with c?

    I don't get exactly why anyone would choose C nowadays.

  11. #11
    Join Date
    Aug 2002
    Location
    Cluj-Napoca,Romania
    Posts
    3,496

    Re: oop with c?

    Quote Originally Posted by NMTop40
    I don't get exactly why anyone would choose C nowadays.
    I think a hardcore C# programmer asks himself the very same question.
    Har Har

  12. #12
    Join Date
    Jun 2002
    Location
    Moscow, Russia.
    Posts
    2,176

    Re: oop with c?

    Quote Originally Posted by PadexArt
    It is possible to simulate OOP in C but I'm not sure if it is worth it. If the decission to use C and not C++ was correct it means that you do not need an OOP approach and that you are aiming for something else.
    It doesn't. There may be external causes forcing to use C.
    "Programs must be written for people to read, and only incidentally for machines to execute."

  13. #13
    Join Date
    Aug 2002
    Location
    Cluj-Napoca,Romania
    Posts
    3,496

    Re: oop with c?

    Quote Originally Posted by RoboTact
    It doesn't. There may be external causes forcing to use C.
    Then the decission to use C is not correct.
    Har Har

  14. #14
    Join Date
    Jun 2002
    Location
    Moscow, Russia.
    Posts
    2,176

    Re: oop with c?

    Quote Originally Posted by PadexArt
    Then the decission to use C is not correct.
    There may be singleton decision space.
    "Programs must be written for people to read, and only incidentally for machines to execute."

  15. #15
    Join Date
    Aug 2002
    Location
    Cluj-Napoca,Romania
    Posts
    3,496

    Re: oop with c?

    Quote Originally Posted by RoboTact
    There may be singleton decision space.
    Ouch.
    Har Har

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured