Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. no matching function for call to 'ParentClass::ParentClass' error in derived class constructor
Forum Updated to NodeBB v4.3 + New Features

no matching function for call to 'ParentClass::ParentClass' error in derived class constructor

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 4.3k 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.
  • N Offline
    N Offline
    Niagarer
    wrote on 7 Sept 2017, 07:38 last edited by Niagarer 9 Jul 2017, 07:42
    #1

    Hey,
    First: I am pretty sure, this is just a tiny mistake, but I am unfortunately stuck right now...
    When I compile my program, I get the error from the title in the cpp constructor of a class ("FunctionNode") that derives from another class ("Node").
    The parent class is ok, everything works, I just get the error in the derived class.
    Here the class header:

    #ifndef FUNCTIONNODE_H
    #define FUNCTIONNODE_H
    
    #include "node.h"
    class FunctionNode : public Node
    {
    public:
        FunctionNode();
    };
    #endif // FUNCTIONNODE_H
    
    

    and the source file:

    #include "functionNode.h"
    FunctionNode::FunctionNode(){} // error here
    
    

    error:

    error: no matching function for call to 'Node::Node()'
     FunctionNode::FunctionNode()
    

    What did I miss?
    Thanks for answers

    1 Reply Last reply
    0
    • S Offline
      S Offline
      sierdzio
      Moderators
      wrote on 7 Sept 2017, 08:19 last edited by
      #2

      You did not initialize the parent class, so compiler tries to automatically initialize it using default constructor Node(), but it is missing.

      You should initialize the parent class manually:

      FunctionNode::FunctionNode() : Node(some, arguments) {}
      

      Or add a default constructor to Node class.

      (Z(:^

      N 1 Reply Last reply 7 Sept 2017, 08:40
      4
      • S sierdzio
        7 Sept 2017, 08:19

        You did not initialize the parent class, so compiler tries to automatically initialize it using default constructor Node(), but it is missing.

        You should initialize the parent class manually:

        FunctionNode::FunctionNode() : Node(some, arguments) {}
        

        Or add a default constructor to Node class.

        N Offline
        N Offline
        Niagarer
        wrote on 7 Sept 2017, 08:40 last edited by
        #3

        @sierdzio Ahh, yes, thanks, I wondered, that it worked with some QObject classes this way, but I forgot to add all default values for arguments in the Node constructor, that I may can not give at this point but later in the program (or calling them with default values here).
        Thanks!

        1 Reply Last reply
        1
        • S Offline
          S Offline
          sierdzio
          Moderators
          wrote on 7 Sept 2017, 08:42 last edited by
          #4

          Happy coding!

          (Z(:^

          1 Reply Last reply
          2

          1/4

          7 Sept 2017, 07:38

          • Login

          • Login or register to search.
          1 out of 4
          • First post
            1/4
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved