I am confused as to why it says I am redefining class LinkedStack on line 14 when I haven't defined it yet. When I remove template <typename T> on line 13, the error goes away. The error also goes away when I remove friend class LinkedStack on line 10. I don't understand why I'm getting this error.
#include <iostream>
usingnamespace std;
template <typename T>
class Node
{
private:
T elem;
Node* next;
friendclass LinkedStack;
};
template <typename T>
class LinkedStack //error: redefinition of 'LinkedStack' as different kind of symbol
{
public:
LinkedStack(); //constructor
int size() const; //size of stack
bool empty() const; //is stack empty?
void push(const T&); //push function
void pop(); //pop function
const T& top(); //return reference of top
private:
Node* top;
};