I took the example code from http://en.cppreference.com/w/cpp/memory/shared_ptr and compiled it locally, compiled it like this:
g++ -std=c++0x -D_GLIBCXX_USE_NANOSLEEP my_file.cpp
When I run it, I got the following output:
Base::Base()
Derived::Derived()
Created a shared Derived (as a pointer to Base)
p.get() = 0x608029, p.use_count() = 1
Segmentation fault
Any idea why it has a seg fault?
I'm fairly new to C++, how would you usually debug this?
Thanks!