0

New programmer here. My .cpp file for the LinkedList class doesn't recognize its .h class. It gives me the error "'LinkedList' is not a class, namespace, or enumeration". Relevant code reproduced below. Any help would be appreciated.

.cpp here:

#include "LinkedList.h"

LinkedList::LinkedList(void)   {
  next = 0;
  headAddress = 0;
}

and .h:

#pragma once
#include "LinkedListInterface.h"

template<typename T>
class LinkedList : public LinkedListInterface
{

public:
  T next*;
  T headAddress*;
    LinkedList(void) {};
    virtual ~LinkedList(void) {};
}
Meriadoc
  • 101
  • 7
    There is indeed no class named `LinkedList`. There's a class template named `LinkedList`. If you are going for an out-of-class definition, that should be `template LinkedList::LinkedList(){...}`. However, see [this](https://stackoverflow.com/questions/495021/why-can-templates-only-be-implemented-in-the-header-file) – Igor Tandetnik Nov 02 '20 at 00:55
  • Also, `LinkedList(void) {};` defines an empty constructor which does nothing. If the intention is to just *declare* it there, and define it later, then remove the `{}` part. – dxiv Nov 02 '20 at 00:57

1 Answers1

0

You miss a semicolon after the definition of the class LinkedList.

class A {
};  // <- here

compiler assumes the definition of the class continuing in the .cpp file.

anthony.hl
  • 73
  • 7