//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.
I believe there was a problem in the configuration of the C ++ compiler. try uninstalling the extensions and the compiler and reinstalling them following the official microsoft guide: link: https://code.visualstudio.com/docs/languages/cpp.
Answers. iostream. h is deprecated and not a standard header. It was used in older programs before C++ was standardized, Functions like cout were defined inside iostream.
Press Ctrl+. to trigger the Quick Actions and Refactorings menu. Select Add file header. To apply the file header to an entire project or solution, select Project or Solution under the Fix all occurrences in: option. The Fix all occurrences dialog will open where you can preview the changes.
You can see an example of a header-units. json file under the installation directory for Visual Studio. For example, %ProgramFiles%\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.30. 30705\include\header-units.
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++
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With