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):

What’s the difference between SoftReference and WeakReference in Java?

From Understanding Weak References, by Ethan Nicholas: Weak references A weak reference, simply put, is a reference that isn’t strong enough to force an object to remain in memory. Weak references allow you to leverage the garbage collector’s ability to determine reachability for you, so you don’t have to do it yourself. You create a weak reference … Read more

Undefined reference to main – collect2: ld returned 1 exit status

It means that es3.c does not define a main function, and you are attempting to create an executable out of it. An executable needs to have an entry point, thereby the linker complains. To compile only to an object file, use the -c option: The above compiles es3.c to an object file, then compiles a file main.c that would contain the main function, and the linker merges es3.o and main.o into … Read more

error: invalid initialization of non-const reference of type ‘int&’ from an rvalue of type ‘int’

C++03 3.10/1 says: “Every expression is either an lvalue or an rvalue.” It’s important to remember that lvalueness versus rvalueness is a property of expressions, not of objects. Lvalues name objects that persist beyond a single expression. For example, obj , *ptr , ptr[index] , and ++x are all lvalues. Rvalues are temporaries that evaporate at the end of the full-expression in which … Read more

c++ “Incomplete type not allowed” error accessing class reference information (Circular dependency with forward declaration)

If you will place your definitions in this order then the code will be compiled The definition of function doSomething requires the complete definition of class Ball because it access its data member. In your code example module Player.cpp has no access to the definition of class Ball so the compiler issues an error.