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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:50:47+00:00 2026-06-13T18:50:47+00:00

i am working on an assignment where i am asked to implement a linked

  • 0

i am working on an assignment where i am asked to implement a linked list in c++. so far everything is working great except for when i am creating a new list. in my method create_list(). after i assign content and an id number to my Field and try to call GetNext() i get an error saying: Request for member 'GetNext()' in 'Node' which is a non-class type '*Field'. I’m still new to the C++ syntax and object oriented programming. What am I doing wrong? I thought by using the line Field *Node = new Field(SIZE, EMPTY); that my variable Node would be of class type Field…?

#include <iostream>
#include <ctype.h>

using namespace std;

typedef enum { EMPTY, OCCUPIED } FIELDTYPE;

// Gameboard Size
int SIZE;  

class Field {

private:
int _SquareNum; 
FIELDTYPE _Content; 
Field* _Next;

public: 
// Constructor
Field() { }

// Overload Constructor
Field(int SquareNum, FIELDTYPE Entry) { _SquareNum = SquareNum; _Content = Entry; }

// Get the next node in the linked list
Field* GetNext() { return _Next; }

// Set the next node in the linked list
void SetNext(Field *Next) { _Next = Next; }

// Get the content within the linked list
FIELDTYPE GetContent() { return _Content; }

// Set the content in the linked list
void SetContent(FIELDTYPE Content) { _Content = Content; }

// Get square / location 
int GetLocation() { return _SquareNum; }

// Print the content
void Print() { 

    switch (_Content) {

        case OCCUPIED: 
            cout << "Field " << _SquareNum << ":\tOccupied\n"; 
            break;
        default:
            cout << "Field " << _SquareNum << ":\tEmpty\n";
            break;
    }

} 

}*Gameboard;

here is my create_list() method:

void create_list()
{
int Element; 


cout << "Enter the size of the board: ";
cin >> SIZE; 
for(Element = SIZE; Element > 0; Element--){
    Field *Node = new Field(SIZE, EMPTY);
    Node.GetNext() = Gameboard; // line where the error is 
    Gameboard = Node;
    }
}
  • 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-06-13T18:50:48+00:00Added an answer on June 13, 2026 at 6:50 pm

    No in the declaration

    Field *Node = new Field(SIZE, EMPTY);
    

    Node is of type pointer to Field.

    The fix is simple if you have a pointer to a class and you want to access a member of that class use ->.

    Node->GetNext() = Gameboard;
    

    I think your code has other errors, and I don’t think that even with this ‘fix’ it’s going to work. Probably what you really want is

    Node->SetNext(Gameboard);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a homework assignment where we are asked to implement an evaluation
I'm working on an assignment to implement insertions into an AVL tree, and I'm
I am working on assignment for school. It manly consists of a method that
I am working on an assignment that asks me to implement an AVL tree.
i`m working on my assignment for univ, and since some parts are not really
I'm working on my assignment of PHP course. The problem that I don't understand
I am working on an assignment and don't get answer for some of questions.
I am working on an assignment for networking where we are supposed to create
I am working on an assignment where one of the problems asks to derive
I am working on an assignment where I need to do calculations with large

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.