Q:

Copy constructor with vector with custom class not working?

I am trying to implement Hashtable via LinkedList for collisions and I am having problem implementing copy constructor inside Hashtable (confused with the const-correctness stuff).
This is  the error I am seeing:
void LinkedList<KVP<T>>::add(const KVP<T> &)' : cannot convert argument 1 from 'const int' to 'const KVP<T> &

Here is my code:
Hashtable:
#include <stdlib.h>
#include <string>
#include <vector>
#include "LinkedList.h"
#pragma once

template <typename T>
struct KVP
{
    KVP() {}
    KVP(const T &data, const std::string &key) : data(data), key(key) {}
    const std::string key;
    T data;
};

template <typename T>
class Hashtable
{
    typedef KVP<T> kvp;
    typedef LinkedList<kvp> list;

    std::vector<list> table;
    std::size_t size;

public:

    Hashtable(int size) : size(size), table(size) {}
    Hashtable(const Hashtable& other) : size(other.size) 
    {
        table = other.table; //this causes problems
    }
    Hashtable& operator=(Hashtable other)
    {
        swap(*this, other);
        return *this;
    }
    ...  
};

Linked List:
#include <stdlib.h>
#include <memory>

#pragma once

template <typename T>
class LinkedList;

template <typename TNode>
class LinkedListIterator
{
    friend class LinkedList<typename TNode::value_type>;
    TNode* p;
public:
    LinkedListIterator(TNode* p) : p(p) {}
    LinkedListIterator(const LinkedListIterator& other) : p(other.p) {}
    LinkedListIterator& operator=(LinkedListIterator other) { std::swap(p, other.p); return *this; }
    void operator++() { p = p->next; }
    void operator++(int) { p = p->next; }
    bool operator==(const LinkedListIterator& other) { return p == other.p; }
    bool operator!=(const LinkedListIterator& other) { return !(p == other.p); }
    const int& operator*() const { return p->data; }
    LinkedListIterator<TNode> operator+(int i)
    {
        LinkedListIterator<TNode> iter = *this;
        while (i-- > 0 && iter.p)
        {
            ++iter;
        }
        return iter;
    }
};

template <typename T>
class Node
{
    friend class LinkedList<T>;
    friend class LinkedListIterator<Node<T>>;
    friend class LinkedListIterator<const Node<T>>;

    Node() : next(nullptr) {}
    Node(const T &data) : data(data), next(nullptr) {}
    Node<T> *next;
    T data;
public:
    typedef T value_type;
};

template <typename T>
class LinkedList
{
    typedef Node<T> node;

    std::size_t size;
    std::unique_ptr<node> head;
    std::unique_ptr<node> tail;

    void init()
    {
        size = 0;
        head.reset(new node);
        tail.reset(new node);
        head->next = tail.get();
    }

public:
    typedef LinkedListIterator<node> iterator;
    typedef LinkedListIterator<const node> const_iterator;

    LinkedList() { init(); }

    LinkedList(const LinkedList& other)
    {
        init();
        const_iterator i = other.begin();
        while (i != other.end())
        {
            add(*i);
            i++;
        }

        head.reset(other.head.get());
        tail.reset(other.tail.get());
    }

    LinkedList(LinkedList&& other)
    {
        size = other.size;
        head = other.head;
        tail = other.tail;
        other.size = 0;
    }

    LinkedList& operator=(LinkedList other)
    {
        swap(*this, other);
        return *this;
    }

    LinkedList& operator=(LinkedList&& other)
    {
        assert(this != &other);     
        while (head->next != tail)
            remove(begin());
        head = other.head;
        tail = other.tail;
        size = other.size;
        other.size = 0;
        return *this;
    }

    virtual ~LinkedList()
    {
        while (head->next != tail.get())
            remove(begin());
    }

    friend void swap(LinkedList& first, LinkedList& second)
    {
        std::swap(first.size, second.size);
        std::swap(first.head, second.head);
        std::swap(first.tail, second.tail);
    }

    void add(const T &value)
    {
        node *first = new node(value);
        first->next = head->next;
        head->next = first;
        size++;
    }

    void remove(iterator& removeIter)
    {
        node *last = head.get();
        iterator i = begin();

        while (i != removeIter)
        {
            last = i.p;
            ++i;
        }

        if (i != end())
        {
            last->next = i.p->next;
            size--;
            delete i.p;
        }
    }

    const int getSize() 
    { 
        return size;
    }

    iterator begin() 
    {
        return iterator(head->next);
    }

    const_iterator begin() const
    {
        return const_iterator(head->next);
    }

    iterator end()
    {
        return iterator(tail.get());
    }

    const_iterator end() const
    {
        return const_iterator(tail.get());
    }
};

On its own LinkedList copy ctor seems to work, e.g. this compiles:
LinkedList<int> list;
LinkedList<int> list2;
list2 = list;

But this doesn't:
Hashtable<int> table1(50);
Hashtable<int> table2 = table1;

edit: Also if I define table with a pointer:
std::vector<list*> table; 

it works, but I don't think this is best way.

A:

Your LinkedListIterator<const Node<T>>::operator* returns const int&, rather than the value type of the LinkedList<T>. Your LinkedList<int> test passed because the template parameter happened to match the hard-coded return type of operator*.

