How to create a vector of class objects in C++?
This is actually a function declaration. The function is called myStack and it returns a vector<Site>. What you actually want is: The type of neighbours at the moment will store copies of the objects, not references. If you really want to store references, I recommend using a std::reference_wrapper (rather than using pointers):