header file
-
hello everybody when i include a header file with space between words of its name then my compiler cannot link them and take error: [sajad@sajad binary search trees]$ g++ binary\ trees.cpp binary trees.cpp:3:73: error: /home/sajad/src/ds/test/binary\ search\ trees/BST_node_base.h: No such file or directory binary trees.cpp:4:63: error: /home/sajad/src/ds/test/binary\ search\ trees/BST.h: No such file or direct while the directory and address is completely true. #include<iostream> #include "/home/sajad/src/ds/test/binary\ search\ trees/BST_node_base.h" #include "/home/sajad/src/ds/test/binary\ search\ trees/BST.h" but when i change the name ,without space between it then it run correct,what can i do to solve this error? also when i include a fileheader and in it use for example cout<<"hello"< using namespace std it work true.does it must be as i write or there is another way to solve this? this is the part of header file: #include<iostream> using namespace std; template <class T>class BS_Tree{ public: bool direction; int n; BST_node<T>* root; BS_Tree(){ root=NULL; } ....
-
hello everybody when i include a header file with space between words of its name then my compiler cannot link them and take error: [sajad@sajad binary search trees]$ g++ binary\ trees.cpp binary trees.cpp:3:73: error: /home/sajad/src/ds/test/binary\ search\ trees/BST_node_base.h: No such file or directory binary trees.cpp:4:63: error: /home/sajad/src/ds/test/binary\ search\ trees/BST.h: No such file or direct while the directory and address is completely true. #include<iostream> #include "/home/sajad/src/ds/test/binary\ search\ trees/BST_node_base.h" #include "/home/sajad/src/ds/test/binary\ search\ trees/BST.h" but when i change the name ,without space between it then it run correct,what can i do to solve this error? also when i include a fileheader and in it use for example cout<<"hello"< using namespace std it work true.does it must be as i write or there is another way to solve this? this is the part of header file: #include<iostream> using namespace std; template <class T>class BS_Tree{ public: bool direction; int n; BST_node<T>* root; BS_Tree(){ root=NULL; } ....
khomeyni wrote:
what can i do to solve this error?
what error ? why would you put spaces between the parts of the path ?
-
hello everybody when i include a header file with space between words of its name then my compiler cannot link them and take error: [sajad@sajad binary search trees]$ g++ binary\ trees.cpp binary trees.cpp:3:73: error: /home/sajad/src/ds/test/binary\ search\ trees/BST_node_base.h: No such file or directory binary trees.cpp:4:63: error: /home/sajad/src/ds/test/binary\ search\ trees/BST.h: No such file or direct while the directory and address is completely true. #include<iostream> #include "/home/sajad/src/ds/test/binary\ search\ trees/BST_node_base.h" #include "/home/sajad/src/ds/test/binary\ search\ trees/BST.h" but when i change the name ,without space between it then it run correct,what can i do to solve this error? also when i include a fileheader and in it use for example cout<<"hello"< using namespace std it work true.does it must be as i write or there is another way to solve this? this is the part of header file: #include<iostream> using namespace std; template <class T>class BS_Tree{ public: bool direction; int n; BST_node<T>* root; BS_Tree(){ root=NULL; } ....
You may either avoid spaces inside the paths or use relative ones. As about the namespace, You have two options:
- specify, as you did,
using namespace std;
- Qualify each (
std
) object with thestd namespace
, e.g.std::cout
instead ofcout
,std::endl
instead ofendl
etc...
:)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] - specify, as you did,
-
hello everybody when i include a header file with space between words of its name then my compiler cannot link them and take error: [sajad@sajad binary search trees]$ g++ binary\ trees.cpp binary trees.cpp:3:73: error: /home/sajad/src/ds/test/binary\ search\ trees/BST_node_base.h: No such file or directory binary trees.cpp:4:63: error: /home/sajad/src/ds/test/binary\ search\ trees/BST.h: No such file or direct while the directory and address is completely true. #include<iostream> #include "/home/sajad/src/ds/test/binary\ search\ trees/BST_node_base.h" #include "/home/sajad/src/ds/test/binary\ search\ trees/BST.h" but when i change the name ,without space between it then it run correct,what can i do to solve this error? also when i include a fileheader and in it use for example cout<<"hello"< using namespace std it work true.does it must be as i write or there is another way to solve this? this is the part of header file: #include<iostream> using namespace std; template <class T>class BS_Tree{ public: bool direction; int n; BST_node<T>* root; BS_Tree(){ root=NULL; } ....
Take out the back-slashes that quote the spaces. That is, change this:
#include "/home/sajad/src/ds/test/binary\ search\ trees/BST_node_base.h"
#include "/home/sajad/src/ds/test/binary\ search\ trees/BST.h"to this
#include "/home/sajad/src/ds/test/binary search trees/BST_node_base.h"
#include "/home/sajad/src/ds/test/binary search trees/BST.h"Oh - but don't, don't, don't use absolute paths in code like that! What happens when the code-base moves? You're screwed, aren't you.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p MVP for 2010 - who'd'a thunk it!
-
Take out the back-slashes that quote the spaces. That is, change this:
#include "/home/sajad/src/ds/test/binary\ search\ trees/BST_node_base.h"
#include "/home/sajad/src/ds/test/binary\ search\ trees/BST.h"to this
#include "/home/sajad/src/ds/test/binary search trees/BST_node_base.h"
#include "/home/sajad/src/ds/test/binary search trees/BST.h"Oh - but don't, don't, don't use absolute paths in code like that! What happens when the code-base moves? You're screwed, aren't you.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p MVP for 2010 - who'd'a thunk it!
Stuart Dootson wrote:
Oh - but don't, don't, don't use absolute paths in code like that! What happens when the code-base moves? You're screwed, aren't you
ok i will do it,i have changed it to :
Stuart Dootson wrote:
#include "/home/sajad/src/ds/test/binary search trees/BST_node_base.h" #include "/home/sajad/src/ds/test/binary search trees/BST.h
and solve my problem. thnx for all answers.