Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot open include file: 'vector.h': No such file or directory

Tags:

c++

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;
like image 547
craftace Avatar asked Jul 18 '11 06:07

craftace


2 Answers

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.

like image 193
Frerich Raabe Avatar answered Nov 03 '22 08:11

Frerich Raabe


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;
like image 28
Patrick Avatar answered Nov 03 '22 10:11

Patrick