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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Subclassing

Subclassing

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++
24 Posts 7 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.
  • V voorugonda prashanth

    can u please give me a example????

    T Offline
    T Offline
    toxcct
    wrote on last edited by
    #4

    class BaseClass {
    int m_iSize;

    public:
    int getSize() { return m_iSize; }
    void setSize(int i) { m_iSize = i; }
    };

    class ChildClass : public BaseClass {
    double m_dPrice;

    public:
    double getPrice() { return m_dPrice; }
    void getPrice(double d) { m_dPrice = d; }
    };

    then, you use it like any object which contains all...

    ChildClass cc;
    cc.setSize(4);


    TOXCCT >>> GEII power

    [VisualCalc 3.0  updated ][Flags Beginner's Guide  new! ] -- modified at 5:30 Friday 12th May, 2006

    M 1 Reply Last reply
    0
    • T toxcct

      class BaseClass {
      int m_iSize;

      public:
      int getSize() { return m_iSize; }
      void setSize(int i) { m_iSize = i; }
      };

      class ChildClass : public BaseClass {
      double m_dPrice;

      public:
      double getPrice() { return m_dPrice; }
      void getPrice(double d) { m_dPrice = d; }
      };

      then, you use it like any object which contains all...

      ChildClass cc;
      cc.setSize(4);


      TOXCCT >>> GEII power

      [VisualCalc 3.0  updated ][Flags Beginner's Guide  new! ] -- modified at 5:30 Friday 12th May, 2006

      M Offline
      M Offline
      Maxwell Chen
      wrote on last edited by
      #5

      toxcct wrote:

      class ChildClass : BaseClass {

      class ChildClass : **public** BaseClass { class ChildClass : **protected** BaseClass { class ChildClass : **private** BaseClass {


      Maxwell Chen

      T V 2 Replies Last reply
      0
      • M Maxwell Chen

        toxcct wrote:

        class ChildClass : BaseClass {

        class ChildClass : **public** BaseClass { class ChildClass : **protected** BaseClass { class ChildClass : **private** BaseClass {


        Maxwell Chen

        T Offline
        T Offline
        toxcct
        wrote on last edited by
        #6

        typo fixed :-O


        TOXCCT >>> GEII power

        [VisualCalc 3.0  updated ][Flags Beginner's Guide  new! ]

        S 1 Reply Last reply
        0
        • T toxcct

          typo fixed :-O


          TOXCCT >>> GEII power

          [VisualCalc 3.0  updated ][Flags Beginner's Guide  new! ]

          S Offline
          S Offline
          Scorpio
          wrote on last edited by
          #7

          but inheretance also seems to do the same thing

          T 1 Reply Last reply
          0
          • S Scorpio

            but inheretance also seems to do the same thing

            T Offline
            T Offline
            toxcct
            wrote on last edited by
            #8

            NiLeSh KoRpE wrote:

            but inheretance also seems to do the same thing

            :~ did you read my 1st post ? "another good term for this is also inheritence" yes, it is exactly the same... 2 different word for the same thing. :zzz:


            TOXCCT >>> GEII power

            [VisualCalc 3.0  updated ][Flags Beginner's Guide  new! ]

            1 Reply Last reply
            0
            • V voorugonda prashanth

              what is subclassing actually?? how do u create a subclass in SDK and MFC? Thanks in advance Regards, Prashanth.v

              V Offline
              V Offline
              VinayCool
              wrote on last edited by
              #9

              ar u frm AP ?

              T V 2 Replies Last reply
              0
              • V VinayCool

                ar u frm AP ?

                T Offline
                T Offline
                toxcct
                wrote on last edited by
                #10

                are you typing with your phone ? :~


                TOXCCT >>> GEII power

                [VisualCalc 3.0  updated ][Flags Beginner's Guide  new! ]

                S V 2 Replies Last reply
                0
                • T toxcct

                  are you typing with your phone ? :~


                  TOXCCT >>> GEII power

                  [VisualCalc 3.0  updated ][Flags Beginner's Guide  new! ]

                  V Offline
                  V Offline
                  VinayCool
                  wrote on last edited by
                  #11

                  No;)

                  1 Reply Last reply
                  0
                  • T toxcct

                    are you typing with your phone ? :~


                    TOXCCT >>> GEII power

                    [VisualCalc 3.0  updated ][Flags Beginner's Guide  new! ]

                    S Offline
                    S Offline
                    Scorpio
                    wrote on last edited by
                    #12

                    Can u brief something about subclassing dialogitem and subclassing window

                    T 1 Reply Last reply
                    0
                    • V VinayCool

                      ar u frm AP ?

                      V Offline
                      V Offline
                      voorugonda prashanth
                      wrote on last edited by
                      #13

                      yes. n what abt u?

                      1 Reply Last reply
                      0
                      • S Scorpio

                        Can u brief something about subclassing dialogitem and subclassing window

                        T Offline
                        T Offline
                        toxcct
                        wrote on last edited by
                        #14

                        search codeproject[^]


                        TOXCCT >>> GEII power

                        [VisualCalc 3.0  updated ][Flags Beginner's Guide  new! ]

                        1 Reply Last reply
                        0
                        • M Maxwell Chen

                          toxcct wrote:

                          class ChildClass : BaseClass {

                          class ChildClass : **public** BaseClass { class ChildClass : **protected** BaseClass { class ChildClass : **private** BaseClass {


                          Maxwell Chen

                          V Offline
                          V Offline
                          VinayCool
                          wrote on last edited by
                          #15

                          Yes u ar correct Max :~

                          1 Reply Last reply
                          0
                          • V voorugonda prashanth

                            what is subclassing actually?? how do u create a subclass in SDK and MFC? Thanks in advance Regards, Prashanth.v

                            V Offline
                            V Offline
                            VinayCool
                            wrote on last edited by
                            #16

                            which company are u working ??

                            V 1 Reply Last reply
                            0
                            • V VinayCool

                              which company are u working ??

                              V Offline
                              V Offline
                              voorugonda prashanth
                              wrote on last edited by
                              #17

                              i'm working for zilog,bangalore. n u?

                              V 1 Reply Last reply
                              0
                              • V voorugonda prashanth

                                i'm working for zilog,bangalore. n u?

                                V Offline
                                V Offline
                                VinayCool
                                wrote on last edited by
                                #18

                                why did u left spatial technologies(I) Ltd,Hyd. ???

                                V 1 Reply Last reply
                                0
                                • V VinayCool

                                  why did u left spatial technologies(I) Ltd,Hyd. ???

                                  V Offline
                                  V Offline
                                  vikramlinux
                                  wrote on last edited by
                                  #19

                                  What a discussion thread and out of context topics !!! .

                                  S 1 Reply Last reply
                                  0
                                  • V vikramlinux

                                    What a discussion thread and out of context topics !!! .

                                    S Offline
                                    S Offline
                                    Scorpio
                                    wrote on last edited by
                                    #20

                                    not really all NiLeSh KoRpE

                                    V 1 Reply Last reply
                                    0
                                    • S Scorpio

                                      not really all NiLeSh KoRpE

                                      V Offline
                                      V Offline
                                      voorugonda prashanth
                                      wrote on last edited by
                                      #21

                                      sorry all.

                                      1 Reply Last reply
                                      0
                                      • T toxcct

                                        subclassing is not a MFC nor SDK concept but a C++ (and even general OO) concept. it means using a base class to reuse its behavior/design/methods and not reinventing the wheel... another good term for this is also inheritence


                                        TOXCCT >>> GEII power

                                        [VisualCalc 3.0  updated ][Flags Beginner's Guide  new! ]

                                        B Offline
                                        B Offline
                                        BadKarma
                                        wrote on last edited by
                                        #22

                                        Is always tought that subclassing was to change the behaviour of a class in a framework without changing the framework. I guess i'm wrong but what is then the correct term for this kind of pattern. Let me explain by a simple example. You create your own windowproc which is then used to overwrite the normal winproc. By using your own windowproc you can change the behaviour of the subclassed window. codito ergo sum

                                        T 1 Reply Last reply
                                        0
                                        • B BadKarma

                                          Is always tought that subclassing was to change the behaviour of a class in a framework without changing the framework. I guess i'm wrong but what is then the correct term for this kind of pattern. Let me explain by a simple example. You create your own windowproc which is then used to overwrite the normal winproc. By using your own windowproc you can change the behaviour of the subclassed window. codito ergo sum

                                          T Offline
                                          T Offline
                                          toxcct
                                          wrote on last edited by
                                          #23

                                          in what way would that be different from what i explained ? you can always inherit from a base class and override some functions do change the behavior, or had some new features... ;)


                                          TOXCCT >>> GEII power

                                          [VisualCalc 3.0  updated ][Flags Beginner's Guide  new! ]

                                          B 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