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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:13:55+00:00 2026-05-31T03:13:55+00:00

I was trying to create a linked list with structs. The idea is to

  • 0

I was trying to create a linked list with structs. The idea is to use 2 different stucts, one which is a node, and another which is a pointer to the nodes (so, I can link the nodes together).

But I wanted to initialize the pointer to the first node as NULL, and create subsequent nodes later:

I am having an error in the 2 constructor methods (List and Polynomial), I can’t use the operator = like the way I am. But I can’t understand why.

struct List
{
    //Data members to hold an array of pointers, pointing to a specific node
    Node *list[100];

    //Default constructor
    List();
};

List::List()
{
    *list[0] = NULL;
}

class Polynomial
{
    public:
    [...]

    private:
        List *poly;                         //Store the pointer links in an array
        Node first_node;
        int val;
};

Polynomial::Polynomial()
{
    poly = new List();
}

/*******************************************************************************************************************************/
// Method   : initialize()
// Description  : This function creates the linked nodes
/*******************************************************************************************************************************/
Polynomial::void initialize(ifstream &file)
{
    int y[20];
    double x[20];
    int i = 0, j = 0;

    //Read from the file
    file >> x[j];
    file >> y[j];

    first_node(x[j], y[j++]);                       //Create the first node with coef, and pwr
    *poly->list[i] = &first_node;                       //Link to the fist node

    //Creat a linked list
    while(y[j] != 0)
    {
        file >> x[j];
        file >> y[j];
        *poly->list[++i] = new Node(x[j], y[j++]);
    }

    val = i+1;                              //Keeps track of the number of nodes
}

I have been getting errors in the Polynomial constructor and the List constructor.

  • 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-31T03:13:56+00:00Added an answer on May 31, 2026 at 3:13 am

    It seems not like the link list. Maybe you need a struct node (right ?) contain information and List contain many node after ? If this two, I has two solutions:

    first. very (and very) common.

    typedef struct nNode{
      int info;
      string name;
      //and any information you want this node has.
      struct nNode *pNext;
    } Node;
    

    Second. Style like I see in your code.

    typedef struct nNode{
      int info;
      string name;
      //and any information you want this node has
    }Node;
    typedef struct nList{
      Node node;
      struct nList *pNext;
    } List;
    

    You see, the second version looks like the first 🙂

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

Sidebar

Related Questions

I'm trying to create 2 linked list with a common intersection node. As I
I'm trying to create a linked list class in Eclipse but I can't get
I'm trying to create a reference based linked list anyone would be able to
I am trying to format a linked list so that it prints 5 nodes
Im trying to create a linked list in c. The twist is that I
I am trying to implement a simple singly linked list of integers which are
I am trying to use a Generic Linked List to hold some WorkFlow steps
I am trying to create a linked list in my program and I am
I must be missing something rather easy? I’m trying to create a linked list
For homework I am supposed to create a circularly linked list using nodes and

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.