Have you run the program with your debugger? Your debugger should be able to tell you exactly where it detects the problem. For example this is what my compiler reports for the call stack after the crash:
Code:
#0 0x45392d std::__shared_ptr<test::Link<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, (__gnu_cxx::_Lock_policy)2>::operator=(this=0x10) (/opt/gcc/6.1.0/include/c++/6.1.0/bits/shared_ptr_base.h:870)
#1 0x453975 std::shared_ptr<test::Link<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >::operator=(this=0x10) (/opt/gcc/6.1.0/include/c++/6.1.0/bits/shared_ptr.h:93)
#2 0x453a38 test::List<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::List(this=0x7fffffffdf40) (main.cpp:66)
#3 0x453598 main() (main.cpp:168)
So with this call stack you would pretty much ignore the first two locations because they are part of the STL and are most likely not the real problem. So then that moves you to the third message, which happens to be on line 66 in your code:
Code:
List() { _size = 0; _first = nullptr; _last = nullptr; _first -> _next = _last ;}
And this line is definitely the problem. You're trying to access a value though a nullptr so the program crashes.
By the way this line is also malformed.
Code:
const size_t getSize() { return _size; }
The const qualifier is probably in the wrong place. It probably should be more like:
Code:
size_t getSize() const { return _size; }
Which tells the compiler that this function won't change any of the class member variables.
Also this line:
Code:
using difference_type = ptrdiff_t;
Since you're not using the using namespace std; clause you need to properly scope the ptrdiff_t type.
Jim