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. Can someone help me fix this part of a recursive class
Forum Updated to NodeBB v4.3 + New Features

Can someone help me fix this part of a recursive class

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 4 Posters 409 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.
  • A Offline
    A Offline
    AI_Messiah
    wrote on last edited by
    #1
    void Node::put_recurse(Node inp, int idx)
    {
        if (children.size() > 0 && curChild < children.size()){
            if (idx > 0){
                children.push_back(inp);
            }else{
                idx--;
                children.at(curChild).put_recurse(inp, idx);
            }
        }
    }
    

    the children and curChild are a part of the Node class

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      And what is the issue ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • A Offline
        A Offline
        AI_Messiah
        wrote on last edited by
        #3

        I get some error message about the type it suggests const, but I add const and it doesn't help

        JonBJ 1 Reply Last reply
        0
        • Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @AI_Messiah said in Can someone help me fix this part of a recursive class:

          children.at(curChild)

          This returns a const ref (or object). Use a function which returns a non-const ref.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          1
          • A AI_Messiah

            I get some error message about the type it suggests const, but I add const and it doesn't help

            JonBJ Online
            JonBJ Online
            JonB
            wrote on last edited by
            #5

            @AI_Messiah said in Can someone help me fix this part of a recursive class:

            I get some error message about the type it suggests const, but I add const and it doesn't help

            When asking for help, you are supposed to copy & paste the error message, which probably shows a line number, and show whatever you tried to resolve. Rather than leaving people to just guess.

            1 Reply Last reply
            0

            • Login

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