Ok first thing,
You are declaring the classes but you have to define them.
Start off by making a header file (.h file) for each class, i.e. every .cpp file should have a .h file. Then in the header file, everything should be surrounded by something like:
1 2 3 4 5 6
|
#ifndef nut_hh_
#define nut_hh_
// ... do your header declarations and forward declarations...
#endif
|
then keep the implementation files (although they do need to debugged) and include the header file for that class.
When I copied over your code to see if I got your error, I did not get it. I got a problem with your classes.h file.
simply using
is not a full definition of a class even if it has a .cpp file. It is a forward declaration. A forward declaration (of lets say class B) tells the compiler in this class (lets call it class A) I am going to use class B in the implementation file (.cpp) of class A but I do not want to include the header file of class B because I do not want to create a large dependency tree (if class C includes class A and class A includes class B in its header then if B is changed, class A will then have to be completely recompiled and then class C will have to completely recompiled - important to understand for large programs. Anyway, a forward declaration is an incomplete definition, you have to actually define the class in its own header file (which you then include in the .cpp file) and in the implementation file you need to include the header for that class which I do not see.
Just saying
means nothing. The compiler just lets you then refer to class in that file but expects a definition elsewhere. if you don't have a definition, the compile will fail with a linking error.
Additionally, I am not sure why you have functions that are supposed to return a value and the only line is
location;
. This does nothing, I'd review that.
Honestly from the looks of it, I would consider making a controller/manager class which means the main() would only have the creation of controller class, creation of your Squirrel, Nut, and Tree classes (which would then be passed to the controller class) and then a Initialize() function in the controller to begin manipulation of the logic to guide you through the program - you could also let the controller class handle the creation of the Squirrel, Nut, and Tree classes. This would make it much easier to manipulate the data within Squirrel, Nut, and Tree classes