Initializing constructor in CPropertyPage

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Vaclav
    New Member
    • Aug 2013
    • 3

    Initializing constructor in CPropertyPage

    Here is a declaration of property class
    class CMyPropertyPage 11 : public CPropertyPage

    Here is the definition
    CMyPropertyPage 11::CMyProperty Page11() : CPropertyPage(C MyPropertyPage1 1::IDD)

    I really do not understand the role of the
    CPropertyPage(C MyPropertyPage1 1::IDD)

    But I need to derive CMyPropertyPage 11 from another CPropertyPage, say CBasePropertyPa ge adn really need to know how to implement the CPropertyPage(C MyPropertyPage1 1::IDD) initialization again.
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    Code:
    class CMyPropertyPage11 : public CPropertyPage
    This says class CMyPropertyPage 11 is a derived class of CPropertyPage

    Code:
      CMyPropertyPage11::CMyPropertyPage11() : CPropertyPage(CMyPropertyPage11::IDD)
    This says the default constructor of CMyPropertyPage 11() calls the base class constructor of CPropertyPage using CMyPropertyPage 11::IDD as an argument.

    The initializer list (:) of CMyPropertyPage 11() guarantees that CPropertyPage:: CPropertyPage(C MyPropertyPage1 1::IDD) is called before the CMyPropertyPage 11() constructor executes.

    It is important that all base class data members are initialized before attempting to initialize derived class members in the event the derived class requires information from the base class in order to proceed.

    Were this not done, when you create a CMyPropertyPage 11 object, the CPropertyPage:: CPropertyPage() constructor would be called instead. The base portion of your CMyPropertyPage 11 object would now be missing the CMyPropertyPage 11::IDD.

    Comment

    • Vaclav
      New Member
      • Aug 2013
      • 3

      #3
      Thank you, I think I got it. At least the basics.
      Now I am still stuck with the next step.
      I need to have all of the the ProperyPagexx have an access to one common instance of a class.
      So I build another BaseProperyPage to instantiate such common class.
      Now I need to have the original ProperyPageXX inherit from the BaseProperyPage which inherits from ProperyPage.

      To do this multiple inheritance the compiler complains that they both inherit from same base and I need to fix than using virtual inheritance. I think I can handle that.
      But I am still unclear how am I going to do the original initialization.

      Basically I have no clue how to make this “idea” work so it compiles, because my syntax is wrong:
      I have deleted all the : so it is little clearer.

      CmyPropertyPage 11::CMyProperty Page11 : (?)

      CPropertyPage(C MyPropertyPage1 1::IDD) (?) original initialization

      CBasePropertyPa ge (?) do I really need this

      Here is partial, still not working, declaration:

      class CMyPropertyPage 11 : public CPropertyPage, virtual public CBasePropertyPa ge


      I am getting tons of errors no matter what I try.
      Maybe I should just put the original initialization inside the constructor?
      I got he whole “property sheet” from VC 6.0 components and obviously need to know some basic before I get to use it for real.

      Comment

      • weaknessforcats
        Recognized Expert Expert
        • Mar 2007
        • 9214

        #4
        You are after a thing called a Singleton. An object for which there is one instance and accessible through a common point.

        There is a design pattern called Singleton that does this.

        Please read: http://bytes.com/topic/c/insights/65...erns-singleton
        Last edited by weaknessforcats; Aug 22 '13, 02:44 PM. Reason: typos

        Comment

        Working...