macos的vscode报错这是怎么回事?

macos的vscode报错这是怎么回事?

SeqList.h
const int MaxSize = 100;
template <class T>
class seqlist
{
public:
    SeqList();//构造函数
    SeqList(T a[],int n);//带参构造函数
    int GetLength();//获取顺序表的长度
    T Get(int i);//获取顺序表的值
    int Locate(T x);//定位x在顺序表中的位置
    void Insert(int i,T x);//将x插入顺序表中的i位置
    T Delete(int i);//删除第i个位置的元素
    void PrintList();         // 顺序表的遍历(输出)
    void Union(SeqList S1);  // 将有序顺序表S1合并到当前有序顺序表中
private:
    T data[MaxSize];//顺序表
    int length;//顺序表的长度
};

seqlist.cpp
#include "seqlist.h"
template <class T>
//无参构造函数
SeqList::SeqList()
{
    length = 0;
}

//有参构造函数
template<class T>
SeqList::SeqList(T a[],int n)
{
    if(n>MaxSize) throw "参数非法";
    for (i = 0;i//插入
template<class T>
void SeqList::Insert(int i,T x)
{
    if(length>=MaxSize)throw"上溢出";
    if(i<1||i>length+1)throw"位置不对";//length+1因为这是顺序表
    for(j = length;j>=i;j--)
        data[j] = data[j-1];
    data[j-1] = x;
    length++;
}

//删除
template<class T>
T SeqList::Delete(int i)
{
    if(length==0) throw "位置错误!";
    T x = data[i-1];//先把要删除的元素存进x
    for(j=i;j//后面的元素向前覆盖一个位置
    {
        data[i-1]=data[i];
    }
    length--;
    rerturn 0;
}

//按位查找
template<class T>
T SeqList::Get(int i)
{
    if(i<0||i>length) throw "位置错误";
    return data[i-1];//返回查找到的元素
}

//按值查找
template <class T>
int SeqList::Locate(T x)
{
    for(i = 0;iif(data[i]==x)return i+1;//返回逻辑序号
    return 0;
}
//顺序表的遍历
template<class T>
void SeqList::PrintList()
{
    for(int i = 0;i" ";
    cout<//将有序顺序表S1合并到当前有序顺序表中
template<class T>
void SeqList::Union(SeqList S1)
{
    
}
main.cpp
#include 
#include "seqlist.h"
using namespace std;
int main()
{
    int a[]={12,21,3,15,8,16};
    SeqList<int> L1;
    SeqList<int> L2(a,6);
    try            // 有异常抛出throw的函数调用要放在try-catch中
    {  L1.Insert(1,10);
    cout<< "顺序表1的第1个元素是: "<Get(1)<Insert(8,10);
    cout<< "顺序表2的第4个元素是: "<Get(4)<catch(const char * msg) {  cout<//输出捕获到的异常信息
    return  0;
}
#include 
#include "seqlist.h"
using namespace std;
int main()
{
    int a[]={12,21,3,15,8,16};
    SeqList<int> L1;
    SeqList<int> L2(a,6);
    try            // 有异常抛出throw的函数调用要放在try-catch中
    {  L1.Insert(1,10);
    cout<< "顺序表1的第1个元素是: "<Get(1)<Insert(8,10);
    cout<< "顺序表2的第4个元素是: "<Get(4)<catch(const char * msg) {  cout<//输出捕获到的异常信息
    return  0;
}


![img](https://img-mid.csdnimg.cn/release/static/image/mid/ask/541421355466180.png "#left")
截屏2022-09-30 23.48.30.png

你这是多个cpp文件编译,需要在task.json的agrs里指定参与编译的文件名。