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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T05:34:59+00:00 2026-05-13T05:34:59+00:00

I keep getting this error – error C2819: type ‘List’ does not have an

  • 0

I keep getting this error –

error C2819: type ‘List’ does not have
an overloaded member ‘operator ->’

i can’t figure out why? help?

Main.cpp –

#include <iostream>
#include <string>
#include <cassert>
using namespace std;

#include "List.h"
#include "Node.h"

The error happens here:

void PrintList ( List list ) {
 Node * temp = list.getFirst();
 Node * temp2 = list->getLast();
 while ( temp->getItemName() != temp2->getName() ) {
  cout << temp.getItemName() << endl;
 }
}

List.h –

#ifndef LIST_H
#define LIST_H

#include "Node.h"
class List
{
private:
 Node * First;
 Node * Last;
 int num_in_list;
public:
 List () { num_in_list = 0; First = NULL; Last = NULL; }
 int get_num_in_list() { return num_in_list; }
 Node * getFirst() { return First; }
 Node * getLast() { return Last; }
 void del_frnt ();
 void push_front (Node *);
 void push_back (Node *);
 void del_last ();
 void add (Node*);
 Node * pop_back ();
 Node * pop_front ();
 int search_item_list (string);
 Node * get (int);
};
#endif

List.cpp –

#include <iostream>
#include <string>
#include <cassert>
#include "Node.h"
#include "List.h"
using namespace std;

Node * List:: get ( int position_of_node ) {
 assert ( First != NULL);
 Node * temp = First;
 for (int i = 1; i < position_of_node; i++) 
  { temp = temp->getNext(); }
 return temp;
}

int List:: search_item_list (string item_searching_for ) {
 assert (First != NULL && num_in_list != 0);
 int counter = 1;
 Node * temp = First;
 while ( temp->getItemName() != item_searching_for || temp->getNext() == NULL )
  { temp = temp->getNext(); counter++; }
 return counter;
}

void List:: add (Node * node_to_be_added) {
 if (num_in_list == 0) { First = node_to_be_added; Last = node_to_be_added; }
 else if (num_in_list != 0 ) {
  Last->setNext(node_to_be_added);
  node_to_be_added->setPrevous(Last);
  Last = node_to_be_added;
 }
 num_in_list++;
}

Node * List :: pop_back ( ) {
 assert (Last != NULL);
 if ( num_in_list > 1) {
  Node * temp = Last;
  Last = Last->getPrevous();
  Last->setNext(NULL);
  temp->setNext(NULL);
  temp->setPrevous(NULL);
  return temp;
 }
 else if ( num_in_list == 1 ) {
  Node * temp = First;
  First = NULL;
  return temp;
 }
 else return NULL;
}

Node * List:: pop_front ( ) {
 assert ( First != NULL && num_in_list > 0);
 if ( num_in_list > 1 ) {
  Node * temp = First;
  First = First->getNext();
  First->setPrevous(NULL);
  temp->setNext(NULL);
  temp->setPrevous(NULL);
  return temp;
 }

 else if ( num_in_list == 1) {
  Node * temp = First;
  First = NULL;
  return temp;
 }
 else return NULL;
}

void List:: del_last ( ) {
 assert ( Last != NULL );
 if ( num_in_list > 1) {
  Node * temp_node = Last->getPrevous();
  Node * new_last = Last;
  temp_node->setNext(NULL);
  delete new_last;
  num_in_list--;
 }
 else if ( num_in_list == 1) {
  Node * temp = First;
  delete temp;
  num_in_list = 0;
  First = NULL;
 }
}

void List:: del_frnt ( ) {
 assert ( First != NULL);
 if ( num_in_list > 1) {
  Node * saveFirst = First;
  First->getNext()->setPrevous(NULL);
     First = First->getNext( );
     delete saveFirst;
     num_in_list--;
 }
 else if ( num_in_list == 1 ) {
  Node * saveFirst = First;
  delete saveFirst;
  num_in_list = 0;
  First = NULL;
 }
}

void List:: push_back (Node * new_node) {
 assert ( Last != NULL );
 Last->setNext(new_node);
 new_node->setPrevous(Last);
 Last = new_node;
 num_in_list++;
}

void List:: push_front (Node * new_node) {
 if ( First != NULL) {
  First->setPrevous(new_node);
  new_node->setPrevous(NULL);
  new_node->setNext(First);
  First = new_node;
  num_in_list++;
 }
 else if ( First == NULL ) {
  First = new_node;
  Last = new_node;
  num_in_list = 1;
 }
}

Node.h –

#ifndef NODE_H
#define NODE_H
#include <string>
using namespace std;

class Node 
{
private:
 string ItemName;
 string Quantity;
 Node * Next;
 Node * Prevous;
public:
 Node () { ItemName = " "; Quantity = " "; }
 void setItemName (string a) { ItemName = a; }
 string getItemName () { return ItemName; }
 void setQuantity (string a) { Quantity = a; }
 string getQuantity () { return Quantity; }
 void setNext (Node * a) { *Next = *a; }
 Node * getNext () { return Next; }
 void setPrevous (Node * a) { *Prevous = *a; }
 Node * getPrevous () { return Prevous; }
};
#endif

Note:I know what I’m doing is just a list, but for a collage class I have to do it 🙂
-Any help / pointers / how to do things better would be GREAT!!!

  • 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-13T05:34:59+00:00Added an answer on May 13, 2026 at 5:34 am

    Can’t do both:

    Node * temp = list.getFirst();
    Node * temp2 = list->getLast();
    

    The former works since you are passing in list by value, but for the latter to work, you need to have the operator-> overloaded. Just use:

    Node * temp2 = list.getLast();
    

    Note: In C++, the syntax for accessing aggregate members (be data members or functions) is:

    T.member if T is an aggregate type
    

    and

    T->member if T is a pointer to an aggregate type
    

    (Ok, I have simplified a bit, but this ought to help you get started.)

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

Sidebar

Related Questions

i keep getting this error: Exception Details: System.NotSupportedException: Cannot serialize member HannaPrintsDataAccess.Customer.CustomerAddresses of type
I keep getting this error: Result consisted of more than one row I have
While developing with Firebug I keep getting this error. pages[x].css(z-index,x) is not a function
I keep getting this error in my windows logs: SharePointSocialNetworking.Facebook b0ceb144-b183-4b66-aa10-39fd9ee42bd4 Could not load
I keep getting this error on Heroku but not locally. any idea why that
I keep getting this error in my production enviroment OpenSSL::SSL::SSLError (hostname was not match
I keep getting this error Object reference not set to an instance of an
I keep getting this error even when I have put reader.php in the same
I keep getting this error: TypeError: Error #1006: setSize is not a function. at
On first load of my Silverlight application I keep getting this error: Could not

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.