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.
  • NiagarerN Offline
    NiagarerN Offline
    Niagarer
    wrote on last edited by Niagarer
    #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
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on 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(:^

      NiagarerN 1 Reply Last reply
      4
      • sierdzioS sierdzio

        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.

        NiagarerN Offline
        NiagarerN Offline
        Niagarer
        wrote on 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
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          Happy coding!

          (Z(:^

          1 Reply Last reply
          2

          • Login

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