In html, you can use "./" when searching for files to use.
For an example, You can simlpy write:
"./My pictures/image.jpg"
Instead of:
"C:\Documents and Settings\Administrator\My Documents\My pictures\image.jpg"
This is useful for people who wants to take the work home on a USB drive
and do not want to change every adress of the files in the project just to
test it. The "./" is in short a way to tell the computer to find the
first folder and then use the adressess to locate the files in the directory
or subdirectorys of the first folder.
Is there a similar way to do this in c++ when telling the compiller to start
looking for a header fil to be included?
If not, is there a way to tell the compiller to link back a directory instead?
There are standard directories in which header files remain. In Linux I think this is '/usr/include/c++/'
If you add your header files in the same directory you can link to them using: #include "headerfile.h"
Use " " instead of < > here to let the compiler know to search in the same directory as the .cpp sourcecode.
. is the current directory.
.. is the parent directory.
If you want to specifiy a file in that directory, you specify the directory seperator, which on Windows is \ and on Unix /
C++ header files are included according to rules. For header files in quotes as in:
#include "myclass.h"
the current directory is searched first, then the directories in the include path. For header files in angle brackes such as:
#include <iostream>
the currect directory is ignored and only the include path is searched.
I did not try but you could attempt to type:
#include "../header.h"
(assuming: /dir1/source.cpp and /header.h)
When I try that, the compiler does not give an error for the includement but when using
contents withing the included header file, it's like it's not even included for use.
It's like the compiler ignores the includement when using "../"
If I type the full adress instead, it all works fine.
Oftenly I just putt comment-tags to make some lines unfunctional
while testing some of the codes.
I simply forgot to delete the comment-tags around an important
line of code this time.
Sorry for the inconvenience!