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

  • SEARCH
  • Home
  • 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 70283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:42:23+00:00 2026-05-10T19:42:23+00:00

template <class T> void BT<T>::inOrder(void (*inOrderPtr)(T&)) { inOrderPtr(inOrder(this->root)); } template <class T> void BT<T>::inOrder(Node<T>*

  • 0
template <class T> void BT<T>::inOrder(void (*inOrderPtr)(T&))  {      inOrderPtr(inOrder(this->root));  } template <class T> void BT<T>::inOrder(Node<T>* root) const  {     if (root->left != NULL)        inOrder(root->left);        //something here     if (root->right != NULL)        inOrder(root->right);  } 

Ok I am trying to create this Traversal via recursion. I actually posted this problem before but I was going about it wrong due to me having to use a function pointer. I don’t understand what I’m suppose to do. I’ve got the public wrapper that calls on the private one… but the public one is the one with the function being passed in so what do I even do with it?? I feel retarded so even if someone were to give me a small hint I’m sure I’d get it. I just don’t know where to go from here.

an example of a code that calls on it is this:

first.inOrder(print_val) 
  • 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. 2026-05-10T19:42:24+00:00Added an answer on May 10, 2026 at 7:42 pm

    This is how to do it properly, but Node::GetItem needs implementing in order for this to be 100% correct:

    template <class T> T& Node<T>::GetItem() const  {     // TODO - implement getting a T& from a Node<T>     return m_item; // possible implementation depending on Node's definition  }  template <class T> void BT<T>::inOrder(void (*inOrderPtr)(T&))  {     inOrder(this->root, inOrderPtr);  }  template <class T> void BT<T>::inOrder(Node<T>* root, void (*inOrderPtr)(T&)) const  {     if (root->left != NULL)        inOrder(root->left, inOrderPtr);      inOrderPtr(root->GetItem());      if (root->right != NULL)        inOrder(root->right, inOrderPtr);  } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my somewhat odd code: template <typename T&> class A { public: void
check this out: template <class T> class Test: public T { public: void TestFunc()
In code: template<class T,int row, int col> void invert(T (&a)[row][col]) { T* columns =
I have this code: struct A{}; template<class T = A> struct B { void
I have a template class that looks something like this: template<class T> class C
Suppose I have this class: template</*some other parameters here */class toggle> class Foo {
When compiling : #include <vector> template<class T> class foo { void bar() { std::vector<T>
Given: template<class T> struct test { void foo(int b); void testFunc( int a )
class IShaderParam{ public: std::string name_value; }; template<class TParam> class TShaderParam:public IShaderParam{ public: void (TShaderParam::*send_to_shader)(
Let's assume we have a template function foo: template<class T> void foo(T arg) {

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.