Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Inheritance in C

Inheritance in C

Scheduled Pinned Locked Moved C / C++ / MFC
oopdatabase
9 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Chandrasekharan P
    wrote on last edited by
    #1

    I dont know if this is the right forum to post this query i wanted to know if we can achieve inheritance and encapsulation in C.

    S CPalliniC J 3 Replies Last reply
    0
    • C Chandrasekharan P

      I dont know if this is the right forum to post this query i wanted to know if we can achieve inheritance and encapsulation in C.

      S Offline
      S Offline
      Stuart Dootson
      wrote on last edited by
      #2

      With some effort, you can mimic inheritance. Use of structs effectively gets you encapsulation.

      C 1 Reply Last reply
      0
      • S Stuart Dootson

        With some effort, you can mimic inheritance. Use of structs effectively gets you encapsulation.

        C Offline
        C Offline
        Chandrasekharan P
        wrote on last edited by
        #3

        a little more explanation will be of great help.

        D 1 Reply Last reply
        0
        • C Chandrasekharan P

          I dont know if this is the right forum to post this query i wanted to know if we can achieve inheritance and encapsulation in C.

          CPalliniC Offline
          CPalliniC Offline
          CPallini
          wrote on last edited by
          #4

          Why don't you use C++, instead?

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
          [My articles]

          In testa che avete, signor di Ceprano?

          C 1 Reply Last reply
          0
          • C Chandrasekharan P

            I dont know if this is the right forum to post this query i wanted to know if we can achieve inheritance and encapsulation in C.

            J Offline
            J Offline
            Jijo Raj
            wrote on last edited by
            #5

            Just read this - Object Oriented Programming in C[^]. Implementing OOP behavior in C is not tough because cfront - the first C++ compiler does compilation by translating C++ source to C and then compile it. If you are insterested, have a look at the cfront source from here[^]. Regards, Jijo.

            _____________________________________________________ http://weseetips.com[^] Visual C++ tips and tricks. Updated daily.

            1 Reply Last reply
            0
            • CPalliniC CPallini

              Why don't you use C++, instead?

              If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
              This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
              [My articles]

              C Offline
              C Offline
              Chandrasekharan P
              wrote on last edited by
              #6

              that is a good qusestion.. :-) i can certainly use C++. but its just the curiosity to know how it can be done. i actually saw in a forum that inheritance can be acheived in c but there was no practical example available in the forum, there was only some explanations that was not satisfactory. so wanted to know more about it . if you could provide that would be great.

              1 Reply Last reply
              0
              • C Chandrasekharan P

                a little more explanation will be of great help.

                D Offline
                D Offline
                David Crow
                wrote on last edited by
                #7

                struct base { }; struct derived : public base { };

                "Love people and use things, not love things and use people." - Unknown

                "The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch

                C 1 Reply Last reply
                0
                • D David Crow

                  struct base { }; struct derived : public base { };

                  "Love people and use things, not love things and use people." - Unknown

                  "The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch

                  C Offline
                  C Offline
                  Chris Losinger
                  wrote on last edited by
                  #8

                  ? struct derived : public base that is not C

                  image processing toolkits | batch image processing

                  D 1 Reply Last reply
                  0
                  • C Chris Losinger

                    ? struct derived : public base that is not C

                    image processing toolkits | batch image processing

                    D Offline
                    D Offline
                    David Crow
                    wrote on last edited by
                    #9

                    I see that I failed to see that the OP wanted a solution in C. :doh:

                    "Love people and use things, not love things and use people." - Unknown

                    "The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups