I have a dynamic array-based class that I'm calling MyList
, that looks as follows:
#ifndef MYLIST_H
#define MYLIST_H
#include <string>
#include <vector>
using namespace std;
template<class type>
class MyList
{
public:
MyList();
~MyList();
int size() const;
type at() const;
void remove();
void push_back(type);
private:
type* List;
int _size;
int _capacity;
const static int CAPACITY = 80;
};
#endif
I also have a another class that I'm calling User
that I want to include an instance of MyList
as a private data member. User looks like this:
#ifndef USER_H
#define USER_H
#include "mylist.h"
#include <string>
#include <vector>
using namespace std;
class User
{
public:
User();
~User();
private:
int id;
string name;
int year;
int zip;
MyList <int> friends;
};
#endif
When I try to compile I get an error in my user.cpp
file:
undefined reference to
MyList::Mylist()
I find this odd because MyList
is completely unrelated to user.cpp
, which only contains my User constructor and destructor.