The problem is that you are trying to create a link vector. The type of object that should be stored in the vector must be assigned, which does not apply to links. The link can only be initialized after the announcement and cannot be changed later.
What you most likely want is
Test t(31415); std::vector<Test> vet; vet.push_back(t);
which creates a copy of t , which is then stored in the vector.
You can see the problem in compiler error messages, although they are rather cryptic. The compiler cannot generate code for *allocator<Test&> , which takes care of memory allocation for objects that will be stored in the vector - there is no way to allocate memory for the link.
source share