I'm having hard times figuring out what's wrong with my approach to including and using header files, especially with classes. What I am doing seems to be exactly what is supposed to be done according to books and tutorials on the net, but in the end it never work.
Change #include "../std_lib_facilities.h" to #include "std_lib_facilities.h"
and put all the files in the same folder.
Make sure that you add classes.cpp to your project.
Yes the code appears to be fine, the errors seem to be linker errors not compile errors. This usually means that you didn't add one or more of the files to your project.
But note although the code appears fine you really don't need to include the std_lib_facilities.h file in either of the files you've shown. And note your error messages have nothing to do with this header file. Th errors are being caused because the linker can't find your class implementation functions, your class constructors in this case.
All the error messages mention token::<something>. Presumably your token.cpp file did not get compiled and linked since the linker can not find any functions in the token class. You do have a token.cpp file, right? If so, what is in it?
In the following snippet, you are mixing declarations and definitions.
You didn't indicate the file name for this snippet. I'm guessing because you have the struct declaration in this file, that this is a header (token.h) file.
You should not be including the definition of your constructors in a header file. This will result in multiply defined symbol linker errors if you include the header in more than one .cpp file. This is not your problem, but it is a problem none the less.
Note that it is okay to include your constructor definitions as part of the structure declaration (lines 9-10), but that is not what you have done.
Forgive me if i have missed something, but you are talking about classes and I see what looks like a constructor token::token(...) yet the code starts out struct token. Should that not be class token? I do not recall a struct needing a constructor, I thought that constructors are used for classes.
The only real difference between a struct and a class is the default access specifiers. A struct defaults to public access where a class defaults to private access. A struct can have member functions just like a class and can also use access sections (public, private, protected).
struct and class are somewhat interchangeable keywords in C++ that differ with the default access of members. By default (no access modifier specified) struct members have public access, class have private access.
Ok. Problem solved. So for some reason, like you said jlb, eventhough the classes.cpp file was both in the folder's project in the windows explorer AND in the codeblocks' project folder it didn't detect it as being part of the project... weird. So I had to add the cpp file to the project. It seemed redundant but apparently codeblocks works this way...
Thanks everyone for your help.