Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6758495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:47:50+00:00 2026-05-26T13:47:50+00:00

My problem is that i get this error binarytree.cpp: In member function ‘void BinaryTree<T>::printPaths(const

  • 0

My problem is that i get this error

binarytree.cpp: In member function ‘void BinaryTree<T>::printPaths(const BinaryTree<T>::Node*) const [with T = int]’:
binarytree.cpp:88:   instantiated from ‘void BinaryTree<T>::printPaths() const [with T = int]’
main.cpp:113:   instantiated from ‘void printTreeInfo(const BinaryTree<T>&, const std::string&, const std::string&) [with T = int]’
main.cpp:47:   instantiated from here
binarytree.cpp:116: error: passing ‘const BinaryTree<int>’ as ‘this’ argument of ‘void BinaryTree<T>::findPaths(BinaryTree<T>::Node*, int*, int) [with T = int]’ discards qualifiers
compilation terminated due to -Wfatal-errors.

I understand that it could be the template that is causing scope issues I dont want it to think that Node member variable of the BinaryTree class How do I accomplish this?

// printPaths()
    template <typename T>
    void BinaryTree<T>::printPaths() const
    {
        printPaths(root);

    }
    template <typename T>
    void BinaryTree<T>::printPath(int path[],int n)
    {
        for(int i = 0; i<n; i++)
            cout << (char)path[i] << " ";
            cout << endl;
    }
    template<typename T>
    void BinaryTree<T>::findPaths(Node * subroot, int path[], int pathLength)
    {
        if(subroot == NULL) return;
        path[pathLength] = subroot->elem;
        pathLength++;
        if(subroot->left == NULL && subroot->right = NULL)
            printPath(path,pathLength);
            else
            {
                findPaths(subroot->left, path, pathLength);
                findPaths(subroot->right,path,pathLength);
            }
    }
    template<typename T>
    void BinaryTree<T>::printPaths(const Node* subroot) const
    {
        int path[100];
        findPaths(subroot,path,0);
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T13:47:50+00:00Added an answer on May 26, 2026 at 1:47 pm

    The problem is that you are calling findPaths() (non-const member) from printPaths() (const member) function. Calling non-const member from const member is not allowed by C++.

    You have to re-write the code by either making both printPaths() as non-const methods or findPaths() and printPath() as const methods.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Running into a problem where on certain servers we get an error that the
i know, this is a realy popular error. But my problem is that my
I'm stuck on an aggregation problem that I can't get to the bottom of.
Afternoon Developers, I have a problem that's beginning to get on my wick. I
I am generating assembly on runtime . Problem is that i cant get rid-of
My problem is that I can't seem to get the image from my bundle
So Here is the Problem, I am trying to get that circle to align
I have some buttons in an UIView. My problem is, that they get cut
What could be the reason, that I get the the Run-Time Error '13' Type
I get this error when I run rake db:migrate *db/migrate//004_add_data_to_measurement_type_and_measurement_unit.rb:3: invalid multibyte char (US-ASCII)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.