Thread: No Constructors

  1. #1
    Registered User
    Join Date
    Jun 2012
    Posts
    3

    No Constructors

    Hi all, so I have a C++ question I can't seem to solve. I come from a Java background but am fairly familiar with C/C++. I have a class I'd like to inherit from:

    (Not the full header but the meat of it is there, I did not write this and can not change it)

    Code:
    namespace bb {
        namespace cascades {
        
        class AbstractPanePrivate;
    
    
        class QT_CASCADES_EXPORT AbstractPane : public UIObject {
            Q_OBJECT
    
    
        public:
            virtual ~AbstractPane();
    
    
        protected:
            /*! \cond PRIVATE */
            explicit AbstractPane(AbstractPanePrivate &_d_ptr);
            /*! \endcond */
    
    
        private:       
    
    
            Q_DECLARE_PRIVATE(AbstractPane)
            Q_DISABLE_COPY(AbstractPane)
    
    
            /*! \cond PRIVATE */
            typedef AbstractPane ThisClass;
            typedef UIObject BaseClass;
            /*! \endcond */
    
    
        };
    }
    }
    What I'd like to do is inherit from it but when I try my compiler tells me there's no "no matching function for call". Okay, understandable it's right, there is no matching function. So how exactly do I go about accomplishing this? Also, what is the reason this class was constructed this way, what is the advantage?

    Here is a partial header for a class that does successfully inherit from AbstractPane so I know it's possible somehow.

    (Again I did not write this, and do not have access to cpp)

    Code:
    namespace bb {
        namespace cascades {
    
    
            class NavigationPanePrivate;
    
    
            class QT_CASCADES_EXPORT NavigationPane : public AbstractPane {
            private:
                Q_OBJECT
                    Q_PROPERTY(QDeclarativeListProperty<bb::cascades::AbstractPane> stack READ stack FINAL)
                    Q_CLASSINFO("DefaultProperty", "stack") 
    
    
                    Q_PROPERTY(bb::cascades::AbstractPane* top READ top NOTIFY topChanged FINAL)
    
    
                    Q_PROPERTY(bool backButtonsVisible READ backButtonsVisible WRITE setBackButtonsVisible
                    RESET resetBackButtonsVisible NOTIFY backButtonsVisibleChanged FINAL)
    
    
            public:
    
    
                explicit NavigationPane();
                virtual ~NavigationPane();
    
    
                bb::cascades::AbstractPane* top() const;
    
    
            private:
                /*! @cond PRIVATE */
                Q_DECLARE_PRIVATE(NavigationPane)
                Q_DISABLE_COPY(NavigationPane)
    
    
                typedef NavigationPane ThisClass; 
                typedef AbstractPane BaseClass;
                /*! @endcond */
            };
        }
    }

  2. #2
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    Are you trying to call the constructor that takes 1 argument, but not supplying the argument perhaps?

    Mind showing what you're doing that doesn't work?
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  3. #3
    Registered User
    Join Date
    Jun 2012
    Posts
    3
    Quote Originally Posted by iMalc View Post
    Are you trying to call the constructor that takes 1 argument, but not supplying the argument perhaps?

    Mind showing what you're doing that doesn't work?
    The problem is I can't create an AbstractPanePrivate. I've searched through all the libs and there's no AbstractPanePrivate header or object file. So I can't think of any way to subclass AbstractPane as no default constructor is available and I can't figure out a way to use the one requiring an AbstractPanePrivate.

    The second code block I provided is basically what I'm doing. Is it even possible that AbstractPanePrivate is not defined anywhere? Is this some sort of trick to stop people from subclassing AbstractPane?

  4. #4
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    Quote Originally Posted by jjetson View Post
    The second code block I provided is basically what I'm doing. Is it even possible that AbstractPanePrivate is not defined anywhere? Is this some sort of trick to stop people from subclassing AbstractPane?
    No trick, because if someone wanted you to not create instances of it then they would just make the constructor private.

    For the NavigationPane class to be creatable, the AbstractPanePrivate class has to exist somewhere. You just need to find it, and use it, or find and derive from it and use that.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  5. #5
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    My guess is that you have - deliberately - not been provided with a complete set of source code, and the AbstractPanePrivate is defined only within a compiled object file. If you look, you will also find that the definition (implementation) of some of AbstractPane's member functions (which presumably manage the lifetime of the AbstractPanePrivate) are also not supplied as source.

    The fact that the code you have is using a considerable number of macros (which you probably have, but have not posted here) makes the code a little harder to understand as well.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. about constructors
    By student111 in forum C++ Programming
    Replies: 13
    Last Post: 06-12-2012, 12:48 PM
  2. constructors
    By shrivk in forum C++ Programming
    Replies: 7
    Last Post: 06-24-2005, 09:35 PM
  3. Constructors
    By syrel in forum C++ Programming
    Replies: 2
    Last Post: 09-21-2004, 01:53 AM
  4. Copy constructors and private constructors
    By Eibro in forum C++ Programming
    Replies: 5
    Last Post: 11-24-2002, 10:16 AM
  5. ()'s in constructors
    By blight2c in forum C++ Programming
    Replies: 2
    Last Post: 03-20-2002, 01:16 AM