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. inheritence of structure

inheritence of structure

Scheduled Pinned Locked Moved C / C++ / MFC
11 Posts 4 Posters 1 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.
  • T Offline
    T Offline
    tasumisra
    wrote on last edited by
    #1

    Hi All, I am new to this forum .... can any body tell me how inheritence can be achieved in structure.. Thanks in advance

    vikas da

    C 2 Replies Last reply
    0
    • T tasumisra

      Hi All, I am new to this forum .... can any body tell me how inheritence can be achieved in structure.. Thanks in advance

      vikas da

      C Offline
      C Offline
      C Mahesh
      wrote on last edited by
      #2

      If you are aware of inheritence using classes then replace the class keyword with struct.(Note: Try this with C++ only) Ex: struct a{ } ; struct a : public b{ private: ---- protected : ----- public : ----- } ;

      T N 2 Replies Last reply
      0
      • T tasumisra

        Hi All, I am new to this forum .... can any body tell me how inheritence can be achieved in structure.. Thanks in advance

        vikas da

        C Offline
        C Offline
        C Mahesh
        wrote on last edited by
        #3

        If you have worked with classes then replace class with struct. Ex: struct a{ } ; struct b : public a{ };

        C 1 Reply Last reply
        0
        • C C Mahesh

          If you have worked with classes then replace class with struct. Ex: struct a{ } ; struct b : public a{ };

          C Offline
          C Offline
          C Mahesh
          wrote on last edited by
          #4

          Please ignore this, as my browser had some problem. thanks Mahesh

          1 Reply Last reply
          0
          • C C Mahesh

            If you are aware of inheritence using classes then replace the class keyword with struct.(Note: Try this with C++ only) Ex: struct a{ } ; struct a : public b{ private: ---- protected : ----- public : ----- } ;

            T Offline
            T Offline
            tasumisra
            wrote on last edited by
            #5

            Thanks Mahesh... But I really didnt understand what is the difference between struct and class other then by default visibility... can u plzzz explain me... Thanks Vikas da

            vikas da

            C 1 Reply Last reply
            0
            • T tasumisra

              Thanks Mahesh... But I really didnt understand what is the difference between struct and class other then by default visibility... can u plzzz explain me... Thanks Vikas da

              vikas da

              C Offline
              C Offline
              C Mahesh
              wrote on last edited by
              #6

              The basic difference between a class and struct is with respect to scope. The class members are default private and struct members are public. In addition to this a struct should be used the way it is done in c and use class where you need attributes and behaviours.

              T G 2 Replies Last reply
              0
              • C C Mahesh

                The basic difference between a class and struct is with respect to scope. The class members are default private and struct members are public. In addition to this a struct should be used the way it is done in c and use class where you need attributes and behaviours.

                T Offline
                T Offline
                tasumisra
                wrote on last edited by
                #7

                so if i start giving always public,private and protected modifier then i can do everything what ever am doing in class and i can replace the class with structure where ever am explicitly specifying the acess modifiers .... is it??? Thanks

                vikas da

                C 1 Reply Last reply
                0
                • T tasumisra

                  so if i start giving always public,private and protected modifier then i can do everything what ever am doing in class and i can replace the class with structure where ever am explicitly specifying the acess modifiers .... is it??? Thanks

                  vikas da

                  C Offline
                  C Offline
                  C Mahesh
                  wrote on last edited by
                  #8

                  Yes.

                  T 1 Reply Last reply
                  0
                  • C C Mahesh

                    Yes.

                    T Offline
                    T Offline
                    tasumisra
                    wrote on last edited by
                    #9

                    Oke. Thanks Mahesh i will try this at home...

                    vikas da

                    1 Reply Last reply
                    0
                    • C C Mahesh

                      If you are aware of inheritence using classes then replace the class keyword with struct.(Note: Try this with C++ only) Ex: struct a{ } ; struct a : public b{ private: ---- protected : ----- public : ----- } ;

                      N Offline
                      N Offline
                      Nemanja Trifunovic
                      wrote on last edited by
                      #10

                      C Mahesh wrote:

                      struct a : public b{

                      You don't even need the public keyword there - with struct inheritance is public by default.


                      Programming Blog utf8-cpp

                      1 Reply Last reply
                      0
                      • C C Mahesh

                        The basic difference between a class and struct is with respect to scope. The class members are default private and struct members are public. In addition to this a struct should be used the way it is done in c and use class where you need attributes and behaviours.

                        G Offline
                        G Offline
                        G Haranadh
                        wrote on last edited by
                        #11

                        C Mahesh wrote:

                        In addition to this a struct should be used the way it is done in c and use class where you need attributes and behaviours.

                        Hi can you please make bit clear about this.:)


                        Nice talking to you. :-O
                        If you judge people, you have no time to love them. -- Mother Teresa

                        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