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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:10:22+00:00 2026-06-02T16:10:22+00:00

For my homework assignment for my C++ class, I have to create a Linked

  • 0

For my homework assignment for my C++ class, I have to create a Linked List data structure. I have two classes at the moment. The List class (which is a template class) and the Link class. The Link class is nested within the List class, however, I am trying to define it in a separate header file. The issues I am having come from my lack of understanding in how the linking process works. Here is what I have.

Contents of List.h

#ifndef _LIST_H_
#define _LIST_H_

template <class T>
class List
{
protected:
  class Link;

public:
  List() : _head(nullptr) { }
  ~List() { }

  void PushFront(T object)
  {
    // !! Attention !!
    // When I uncomment this line I get the error:
    // error C2514: 'List<T>::Link' : class has no constructors...
    // My problem is the compiler doesn't know what Link is yet (I'm assuming).

    //_head = new Link(object, _head);
  }

protected:
  Link* _head;
};

#endif // _LIST_H_

Contents of Link.h

#ifndef _LINK_H_
#define _LINK_H_

#include "List.h"

template <class T>
class List<T>::Link
{
public:
  Link(T object, Link* next = nullptr)
    : _object(object), _next(next) { }
  ~Link() { }


private:
  T     _object;
  Link* _next;
};

#endif // _LINK_H_

Contents of main.cpp (entry point)

#include "List.h"

int main()
{
  int b = 5;
  List<int> a;
  a.PushFront(b); // If I comment this line, then the code compiles fine.
}

I’m sure this is a linking error that’s occurring. Similar to this error on Microsoft’s site that I looked up (http://msdn.microsoft.com/en-us/library/4ce3zbbc.aspx), however, I’m not sure how to resolve it.

  • 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-02T16:10:23+00:00Added an answer on June 2, 2026 at 4:10 pm

    With how the #includes are done, the compiler isn’t looking at Link.h – so it can’t find and generate the class it needs.

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

Sidebar

Related Questions

For my homework assignment, I have to create a linked list and it must
Note: This is a homework assignment. I have two classes, one inherits from the
Have a homework assignment in which I'm supposed to create a vector of pointers
I've got a homework assignment where I have a base class Package, and two
For a homework assignment, I'm working with the following. It's an assigned class structure,
Greetings I've been working on a homework in which I must create a linked
I have the following assignment for homework. Requirements Design a class called TokenGiver with
I have a homework assignment which asks to have the user input a date
I have a linked list question that stems from this homework prompt I am
Good evening everyone, I have a quick question on a homework assignment my class

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.