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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:59:56+00:00 2026-05-28T00:59:56+00:00

i wana create a bst tree in c++ but i have a syntax error

  • 0

i wana create a bst tree in c++ but i have a syntax error in this code :

#pragma once
#include "BSTNode.h"
using namespace std;

class BST
{
private:
    BSTNode* root;
public:
    BST(void);
    bool insert(int );
    int search(int);
    ~BST(void);
};

and BSTNode is:

#pragma once
#include "BST.h"

class BST;

class BSTNode
{
    friend  class BST;
private:
    int data;
    BSTNode * LeftChild, *RightChild;
public:
    BSTNode(void);
    int getData();
    ~BSTNode(void);
};

my error is:

Error   1   error C2143: syntax error : missing ';' before '*'

i think dont have error .please help me!

  • 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-28T00:59:57+00:00Added an answer on May 28, 2026 at 12:59 am

    You have a circular include, with 2 files, and because of the #Pragma once, both files are only included once, and therefore BSTNode is parsed first and includes BST, but then BST is not including BSTNode anymore (because it is pragma once).

    this leads to BST not knowing what a BSTNode is, solution would be:

    Removing the include and forward declaring the class like such:

    #pragma once
    using namespace std;
    
    class BSTNode;  //Forward declare class so that BST knows BSTNode (move include to .cpp file)
    
    class BST
    {
    private:
        BSTNode* root;
    public:
        BST(void);
        bool insert(int );
        int search(int);
        ~BST(void);
    };
    

    Example of main function:

    int main( int argc, const char* argv[] )
    {
        printf( "\nHello World\n\n" );
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wana develop a multi-player chess using c# but I don't have any idea
i have made a urdu editor using swing in java and now wana add
i am new to zend framework i wana know why we are using this
what i want to do is that i wana show user this Showing 1
I have to keep USD as base currency to enable PayPal but I have
I wana define a simple function in my program so I added this prototype
hi all i wana ask a question about crystal reporting in vs 2008 lets
I have been looking into MeeGo, maemo, Android architecture. They all have Linux Kernel,
I have been doing Windows programming in .Net since last two years. Now I
I have a backup system..... that backs up a folder every 5 minutes. The

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.