Cannot open include file: 'vector.h': No such file or directory
At the top of the file, I have:
#include "vector.h"
then I do a:
vector<vtarg> targVector;
and got the following error
Cannot open include file: 'vector.h': No such file or directory
Am I missing out something? I tried #include "vector" even more errors.
#include "afxwin.h"
#include "vector.h"
// CTargDlg dialog
class CTargDlg : public CDialog {
// Construction
public:
CTargDlg(CWnd* pParent = NULL);
// standard constructor
vector<vtarg> targVector;
开发者_开发知识库
You need to use
#include <vector>
instead, without the .h
file extension. Furthermore, the vector
template lives in the std
namespace, so you should define your vector like
std::vector<vtarg> targVector;
Also make sure to include whatever headers are necessary for vtarg
.
You made 3 errors.
First, the include file is called vector, not vector.h.
Second, this vector is an include that's part of the standard C++ run-time library, you need to use the <> include construction, like this:
#include <vector>
Third, the vector class (actually templated class) belongs to the std namespace. So you should write:
std::vector<vtarg> targVector;
The header file is called vector
, not vector.h
.
In general, standard C++ headers do not have the .h
suffix.
If you get "even more errors" wen you #include <vector>
, then you'll need to solve those errors. But since you haven't said what those errors are, it's kind of hard to help you with that.
There is no "vector.h"
. The header file for std::vector is <vector>
. Indeed, all of the C++ standard library headers (save for the C-compatibility ones) do not have a ".h" at the end of them.
try this alternative
include "vector"
some compilers, like visual c++ 2010, support this type of notations.
Also if it is a .c file for example xy.c use include"xy".
#include "vector.h"
is actually the correct way of using this if you are using the stanford library collection.
https://www.stanford.edu/class/cs106b/cppdoc/Vector-class.html
The problem is that I don't think most compilers are set up to include the stanford library so the file is something you're going to have to include yourself I think.
精彩评论