Using Classes I have written ?!

Hey everyone (:
so, coming from java, i am a little confused how i properly use classes that i have written.
Here s the setup: i have written a class tokenizer in its own directory with a header, an internal header and several source files.
I have then written a class expression in a different folder. this class needs a tokenizer to function. do i use
#include <tokenizer.h>
to make everything i need available? research on the internet left me a bit confused as to when use "tokenizer.h" and <tokenizer.h>, and for the latter, I have to include a compiler flag, to tell g++ where to look for that header file? Is it even generally a thing to #include all classes that you are going to use? As i said, i come from java and as long as i have my different classes in the same package, i am free to use them. but as i understand it, the equivalent or the closest thing to a package is a namespace in c++, which we did not even cover yet.
So yea, a bit of confusion, and i cannot yet test everything as i am implementing a proper main function (in which i have to include both classes headers?!) and fighting with make.
Anything to help me out would be greatly appreciated, am having a little bit of a time struggle :D


quick edit:
in a constructor, can i use :
Expression::Expression(Tokenizer tokenizer)


as i would do with primitive datatypes? again, probably a question a compiler error may answer :<<
Last edited on
#include with <...> means the preprocessor should chect the default location for the header file but with "...", you will give a location of your choice, or just the name of the header+it's extension(.h), if it is in the same directory.

The difference between
#include <someFile>
#include "someFile"
is left to the implementor. C++ doesn't specify how they are to differ in the order in which they search directories for the file named. They could both do exactly the same thing. They could do different things on different implementations.

If #include "someFile" fails, it will pretend it was #include <someFile> and try again.

In the 2003 C++ standard this is section 16.2
Last edited on
Topic archived. No new replies allowed.