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 7606823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:30:21+00:00 2026-05-31T00:30:21+00:00

I am getting an error in *insert_nodes function: error: expected constructor, destructor, or type

  • 0

I am getting an error in *insert_nodes function:

error: expected constructor, destructor, or type conversion before ‘(‘ token

I also have a problem in the same function, it sais that i have to redeclare the ‘int nodes’ as a parameter in the function. but i think it’s not necessary to write it like this:

*insert_nodes(start, int nodes)

instead of being like this:

*insert_nodes(start,nodes)

Another error that a get is in getch(). While compiling in Netbeans, it just shows an error on that place but it doesn’t mention what type of error.

struct tree_traversal
{
    int data;
    tree_traversal *left; //left subtree
    tree_traversal *right; //right subtree
};

tree_traversal *insert_nodes(tree_traversal *start, int nodes);
void preOrderTraversal(tree_traversal *start);
void postOrderTraversal(tree_traversal *start);
void inOrderTraversal(tree_traversal *start);
int counter = 1;

int main(int argc, char **argv)
{
    int choice, nodes;
    do
    {
        switch(choice)
        {
             case 1:
             cout<<"\n\t\a\a Enter the Values:\a\a";
             cin>>nodes;
             start=insert_nodes(start,nodes);
             break;

             case 2:
             cout<<"\n\t\a\a The Values for In-Order Tree traversal is: \a\a"<<endl;
             preOrderTraversal(start);
             break;

             case 3:
             cout<<"\n\t\a\a The Values for In-Order Tree traversal is: a\a"<<endl;
             postOrderTraversal(start);
             break;

             case 4:
             cout<<"\n\t\a\a The Values for In-Order Tree traversal is: \a\a"<<endl;
             inOrderTraversal(start);
             break;

             case 5:
             exit(0);
        }
    } while(choice != 5);
    return 0;
}

tree_traversal *insert_nodes(tree_traversal *start, int nodes)
{
    if(start == NULL)
    {
        start = new tree_traversal;
        start ->left = start ->right = NULL;
        start ->data = nodes;
        counter++;
    }
    else if(counter%2 == 0)
        start ->left = insert_nodes(start ->left,nodes);
    else
        start ->right = insert_nodes(start ->right,nodes);

    return(start);
}

void preOrderTraversal(tree_traversal *start)
{
    if(start != NULL)
    {
        cout<<start ->data;
        preOrderTraversal(start->left);
        preOrderTraversal(start->right);
        getch();
    }
}

void postOrderTraversal(tree_traversal *start)
{
    if(start != NULL)
    {
        postOrderTraversal(start->left);
        postOrderTraversal(start->right);
        cout<<start ->data;
        getch();
    }
}

void inOrderTraversal(tree_traversal *start)
{
    if(start != NULL)
    {
        inOrderTraversal(start->left);
        cout<<start ->data;
        inOrderTraversal(start->right);
        getch();
    }
}
  • 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-31T00:30:22+00:00Added an answer on May 31, 2026 at 12:30 am
    *insert_nodes(start, int nodes)
    

    should be

    tree_traversal *insert_nodes(tree_traversal *start, int nodes)
    ^^^^^^^^^^^^^^^              ^^^^^^^^^^^^^^^
    

    You forgot to mention the data type for the return type & function argument in function definition.

    Yes, You need to specify the data types of the function arguments in the function definition.

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

Sidebar

Related Questions

Hi I am getting the error message error: expected initializer before '<' token every
I am getting an error when I try to insert an item into a
I'm getting this error: -[NSCFArray insertObject:atIndex:]: attempt to insert nil Here is the .m
Am trying to insert XML into XML Column.. getting following error: . Msg 6819,
getting error while try to start service
I am getting error trying to run my asp code for executing stored proc.
I'm getting error: Unrecognised selector sent to instance, upon inspection, I see there is
I wrote following code...but i am getting Error like: Error 1 'LoginDLL.Class1.Login(string, string, string)':
hi im new to c# and was trying to code but getting error can
at the moment im loading xml and i am getting error: System.Xml.XmlException: ' ',

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.