c++classheader-files

Why VScode display"'iostream' file not found"in .h file?


//vector.h
#ifndef MYVECTOR_H_
#define MYVECTOR_H_

#include<iostream>
#include<vector>
using namespace std;

class vectors
{
public:
    vectors(void);
    ~vectors(void);
    vectors(int *vec,int n);
    vectors(vectors &a);
    friend vectors operator + (vectors a, vectors b);//加法
    friend vectors operator - (vectors a, vectors b);//减法
    friend vectors operator ++(vectors a);//前自增
    friend vectors operator ++(vectors a,int n);//后自增
    friend vectors operator --(vectors a);//前自减
    friend vectors operator --(vectors a,int n);//后自减
    friend vectors operator * (vectors a,vectors b);//数乘

    void Display();//显示函数

private:
    int * Vec;//向量指针
    int N;//维数
};

vectors::vectors(void)
{

}

}
#endif

I'm writing a header file by C++ in VScode, but VScode show me:

'iostream' file not found

In cpp file, it never happens. I think I should install all it need. And I never meet it before.So I don't know how to do with it.

Ok, I try to give more details.

I use vscode to write code. In last codes, I just used '.cpp' files, so I haven't get an error report. But in this time, I try to write my header file as above, vscode tell me:iostream' file not found. I can't correct it. So I ask someone for help.


Solution

  • You can try recognize the compiler. Open command palette CTRL+SHIFT+P, type C/C++: Edit Configurations (UI) and open, then choose your compiler path, for instance, C:/MinGW/bin/g++.