Missing type specifier error using templates

So I am just trying to start up fresh code that was given, and I know I have a template or syntax error. I am getting a "missing type specifier" error for the constructor "LinkedSet();
My other error that's above the constructor is for "Node<ItemType>* getPointerTo(const ItemType& target) const;"
"getPointerTo" is the part with the error saying "is not a member of global namespace"

This is the header file:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#ifndef LINKED_SET_
#define LINKED_SET_

#include "SetInterface.h"
#include "Node.h"

namespace cs_set {

    template<class ItemType>
    class LinkedBag : public SetInterface<ItemType>
    {
    private:
        Node<ItemType>* headPtr;
        int itemCount;

        Node<ItemType>* getPointerTo(const ItemType& target) const;

    public:
        class ItemNotFoundError {};
        LinkedSet();
        LinkedSet(const LinkedSet<ItemType>& aSet);
    };
}

#include "LinkedSet.cpp"
#endif


Here is the .cpp:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "Node.h"
#include "LinkedSet.h"
#include <cstddef>
#ifndef LINKED_SET_CPP
#define LINKED_SET_CPP

namespace cs_set
{

    template<class ItemType>
    LinkedSet<ItemType>::LinkedSet() {
        headPtr = nullptr;
        itemCount = 0;
    }
    template<class ItemType>
    Node<ItemType>* LinkedSet<ItemType>::getPointerTo(const ItemType& anEntry) const {
        bool found = false;
        Node<ItemType>* curPtr = headPtr;

        while (!found && (curPtr != nullptr)) {
            if (anEntry == curPtr->getItem()) {
                found = true;
            }
            else {
                curPtr = curPtr->getNext();
            }
        }

        return curPtr;
    }
}
#endif 
Last edited on
Well I put "#ifndef LINKED_SET_CPP
#define LINKED_SET_CPP" above my include statements in .CPP, but that didn't change anything.

Dammit, I see it now. On line 10 in the Header file I missed a class named Linkedbag, I missed changing it to LinkedSet, now the errors are gone!
Last edited on
Topic archived. No new replies allowed.