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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:28:02+00:00 2026-05-30T02:28:02+00:00

in Line 3 Node next; the Compiler gives me an incomplete type error. I

  • 0

in Line 3 “Node next;” the Compiler gives me an incomplete type error. I think it treat it as a member function not an Attribute. What’s wrong in that Definition?

class Node {
private:
            Node next;
            Node previous;
            int value;
            int min;
public:

            Node(int value) {
                this.value = value;
                this.min = value;
            }


            void insert(Node node) {
                if (this.next != null) {
                    this.next.insert(node);
                }
                else {
                    this.next = node;
                    node.previous = this;
                }
            }
}
  • 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-30T02:28:04+00:00Added an answer on May 30, 2026 at 2:28 am

    First of all, this is a pointer, not a reference, so you need to replace all this. with this->.

    Secondly, you cannot store an instance of a class inside that class because the size of the class would be incalculable. You can only store pointers or references to the class inside the class itself, because the compiler can calculate the size of a pointer or reference to any class without having to have any details of the class (because these pointers/references are all the same size regardless of the underlying object). Change

    Node next;
    Node previous;
    

    to

    Node* next;
    Node* previous;
    // or Node* next, *prev;
    

    And change

    void insert(Node node)
    

    to

    void insert(Node* node)
    

    You also need to initialise the member pointers to NULL (not null) in the constructor of your object (because C++ doesn’t initialise variables that are intrinsic (built-in) types (like pointers) for you):

    Node(int value) {
        this->previous = NULL;
        this->next = NULL;     // or: previous = next = NULL;
    
        this->value = value;
        this->min = value;     // or: this->value = min = value;
    }
    
    // or with initialiser lists (but don't get confused if you don't understand)
    // Node(int value) : previous(), next(), value(value), min(value) { }
    

    Additionally, I (like everyone else) have deduced (from your use of objects like they are references and your use null instead of NULL and of the words ‘method’ and ‘attribute’) that you are a Java or C# programmer learning C++. Please stop now and read a good book on C++, because C++ is nothing like Java or C#, and if you try to use your C#/Java experience when programming C++ then you will only end up ripping your own head off out of frustration.

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

Sidebar

Related Questions

I am trying to use GWT xml parser but the compiler throws next [ERROR]
I have the following XPATH line: //det[@nItem=1]/prod/cProd That successfully selects the desired node using
break line tag is not working in firefox, neither in chrome. When i see
The line where this error was called from is this: $celkova_suma=mysql_result($c_res, 0, 0)+mysql_result($d_res, 0,
The line-height property usually takes care of vertical alignment, but not with inputs. Is
The line is function info() { emacs -eval (progn (setq Man-notify-method 'bully) (info \$1\))
I'm able to go through the first function....but the second func is not running....getaction
It crys that line: List_Node * node = (List_Node*) malloc(sizeof(List_Node)); fails on : 1>list.c(31):
Is there a way to read ahead one line to test if the next
I'm trying to read a text file and store each line in a node

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.