I'm working on a project, and inside of the project I've separated my own classes and functions into a directory called base_lib. When compiling the project, I keep getting an undefined reference error for one of the classes in this library. I have been trying to find the answer on many different forums and ultimately just decided to ask it myself. The code:
stack.h
#ifndef __STACK_H
#define __STACK_H
namespace stacker
{
/*******
My code here
*******/
}
#endif
stack.cpp
#include "stack.h"
#include <iostream>
using namespace std;
template <typename var>
stacker::Stack<var>::Stack()
{
head = nullptr;
tail = nullptr;
}
fix.h
#ifndef __FIX_H
#define __FIX_H
#include <iostream>
#include <string>
namespace fixes
{
/*******
My code here
*******/
}
#endif
fix.cpp
#include "fix.h"
#include "base_lib/stack.h"
#include <iostream>
#include <string>
using namespace std;
using namespace stacker;
main.cpp
#include <iostream>
#include "fix.h"
#include "base_lib/functions.h"
using namespace fixes;
using namespace mine;
using namespace std;
The compiler error
C:\...:fix.cpp:(.text+0xa2): undefined reference to `stacker::Stack<char>::Stack()'
...
Does anyone have any tips or tricks?