g++编译错误.h文件
g++ compile error .h file
我试图在Linux Ubuntu 10.10中使用g++编译。cpp文件,当我试图编译此代码
#include <iostream>
#include <vector>
#include <"writeVector.h"
#include <"insertionSort.h">
using namespace std;
int main()
{
int n;
int i;
vector<int> V;
cout << "Enter the amount of numbers you want to evaluate: ";
cin >> n;
cout << "Enter your numbers to be evaluated: " << endl;
while (V.size() < n && cin >> i){
V.push_back(i);
}
InsertionSort(V);
write_vector(V);
return 0;
}
我有两个。h文件在同一个文件夹,但它一直说我的writeVector.h
文件或文件夹不存在。
这是我的writeVector.h
文件的样子
#include <iostream>
#include <vector>
using namespace std;
template <typename T>
void write_vector(const vector<T>& V)
{
cout << "The numbers in the vector are: " << endl;
for(int i=0; i < V.size(); i++)
cout << V[i] << " ";
}
insertionSort.h
file
#include <iostream>
#include <vector>
using namespace std;
void InsertionSort(vector<int> &num)
{
int i, j, key, numLength = num.length( );
for(j = 1; j < numLength; j++) // Start with 1 (not 0)
{
key = num[j];
for(i = j - 1; (i >= 0) && (num[i] < key); i--) // Smaller values move up
{
num[i+1] = num[i];
}
num[i+1] = key; //Put key into its proper location
}
return;
}
变化
#include <"writeVector.h"
#include <"insertionSort.h">
#include "writeVector.h"
#include "insertionSort.h"
#include "filename"
用于本地头文件,由您制作。
#include <filename>
用于头文件全局包含在c++中,系统头文件
没有<"filename">
这样的语法
#include <"writeVector.h"
该代码无效。下面任意一行都可以:
#include "wrtieVector.h"
#include <writeVector.h>
,但后者保留给system标头。
相关文章:
- C++系统找不到指定的文件错误
- C++语法头文件错误
- C++生成文件错误"implicit entry/start for main executable"
- C++/生成文件错误:未定义对"main"的引用
- VS2019:资源文件错误:中性(默认)(未知子语言:0x8)
- C++程序不制作文件(错误)
- 安卓工作室 |CPP 文件错误错误: 位图库中对"AndroidBitmap_unlockPixels"的未定义引用
- "what does ":*** [可执行文件] 错误 1 " mean ?"
- 如何修复使用VScode调试器gcc调试时的"找不到文件"错误
- 在课堂上创建了一个朋友,给出"无输入文件"错误
- Qt .exe文件错误
- c++ 添加具有写入文件错误的文本变量
- 无法转换 .CATPart 文件.错误:输入文件路径似乎包含不支持的字符
- 写入文本文件错误,QT
- C++写入文件错误
- Windows Subsystem for Linux (WSL) 下的间歇性随机"找不到文件"错误
- 犰狳读取MAT文件错误
- 无法求解FullPathForFilename:COCOS2DX中可能缺少文件错误
- C Wininet FTP列出了许多文件错误
- 生成文件错误 - 找不到文件 - *.cpp