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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:12:04+00:00 2026-05-16T23:12:04+00:00

Okay, I’m making a project that implements a Double Linked List using classes, templates

  • 0

Okay, I’m making a project that implements a Double Linked List using classes, templates and structures.
I constantly get the error:

doublelinklist.h(21) : error C2955: 'Node' : use of class template requires template argument list

when declaring the head and tail of a node in the LinkedList class.

DoubleLinkList.h:

#ifndef DOUBLELINKLIST_H
#define DOUBLELINKLIST_H
#ifndef NULL
#define NULL 0
#endif
//#include <stdio.h>
//#include <string>

template <class T>
struct Node 
{
 T val;
 Node * next;
 Node * prev; //both of these are self-referential data types/structures
};

template <class T>
class LinkedList
{
private:
 static Node * head; //C2955
 static Node * tail; //C2955
public:
 bool push(T);
 //bool pop();
 //T at(); //C2146
 //bool clear();

 LinkedList()
 {
  /*static Node * */head = NULL;
  /*static Node * */tail = NULL;
 }
 ~LinkedList()
 {}
};

#endif

DoubleLinkList.cpp

#include "DoubleLinkList.h"

template <class T>
bool LinkedList<T>::push(T pushMe)
{
 Node * newN = new Node;

 newN->next = NULL;
 newN->prev = NULL;

 if(this->head == NULL)
 {
  head = newN;
  head->val = pushMe;
  tail = newN;
  printf("the value in the head is %d\n", head->val);
  return true;
 }

 newN->prev = tail;
 tail->next = newN;
 newN->pushMe;
 tail = newN;

 printf("The value in the head is %d\n", head->val);
 return true;
}

//bool LinkedList::pop(int remove_where)
//{
// Node * toRemove = at(remove_where);
//
// if(toRemove == head)
// {
//  toRemove->next->prev = NULL;
//  head = toRemove->next;
// }
//
// else if(toRemove = tail)
// {
//  toRemove->prev->next = NULL;
//  tail = toRemove->prev;
// }
// 
// else
// {
//  toRemove->prev->next = toRemove->next;
//  toRemove->next->prev = toRemove->prev;
// }
//
// delete toRemove;
//
// return true;
//
//}
//
//T LinkedList::at()
//{
// 
// 
//}
//
//LinkedList::clear()
//{
// 
//
//}

main.cpp

/*

1) Implement a Double-Linked List using templates and classes in C++.
   You may use the STL type "List" as a reference. 
   A) Don't forget to implement a NODE class...
   B) Don't forget to implement a class that is the actual list...
        i) You need to have AT LEAST:

            Push
            Pop
            At
            Clear 

2) Write a program that tests the functionality of your list class with the data types "int" and "std::string".
*/
#include <stdio.h>
#include <string>
#include "DoubleLinkList.h"

//template <class T>
int main()
{
    int x = 5;
    LinkedList<int> derp;
    derp.push(x);
    return 0;    
}
  • 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-16T23:12:05+00:00Added an answer on May 16, 2026 at 11:12 pm

    Error C2955 (link) relates to the absence of a type argument list to types that require one. In your code you reference the type Node which is actually a template and requires a type argument list. The fixes are below:

    First of all, in DoubleLinkedList.h in the declaration of LinkedList (in the private: section at the top):

    static Node * head;
    static Node * tail;
    

    should be (they should also not be declared static since I’m pretty certain each individual linked list needs its own head and tail):

    Node<T> * head;
    Node<T> * tail;
    

    since Node is actually the template class Node<T> and requires the type parameter itself.

    Similarly in DoubleLinkedList.cpp in the push method:

    Node * newN = new Node;
    

    should be:

    Node<T> * newN = new Node<T>;
    

    for the same reason.

    Furthermore, template definitions should be defined in header files and the header files included using #include, e.g. #include "DoubleLinkedList.h", (and not compiled as you would .cpp files) since template expansion to produce concrete versions of the classes is performed by the preprocessor. Finally, there is also a problem with newN->pushMe; in your definition of LinkedList<T>::push: no such method exists. Fix these issues and there’s a chance it might compile! Beyond that I don’t vouch for the correctness of the code.

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

Sidebar

Related Questions

Okay so I can't figure this out. Like a file that I using grep
Okay, so I know that using eval() isn't great, but I haven't been able
Okay so I have a form that is using PHP to mail to an
Okay, next PHPExcel question. I have an HTML form that users fill out and
okay, i'm setting up a multi-user chat system. i have a messages table, that
Okay, so I'm trying to make a game that uses this algorithm: http://www.codeproject.com/Articles/15573/2D-Polygon-Collision-Detection But
Okay say your using a app, and you opened a new activity and then
Okay, I am using a custom tab bar (not a tab based app) but
Okay, I have hundreds of .net controls with text attributes that needs to be
Okay, I'm reading about Linux kernel development and there are some code snippets using

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.