令牌之前的预期声明'}'

expected declaration before '}' token

本文关键字:声明 令牌      更新时间:2023-10-16

我知道有额外的{或}时知道此错误消息。但是我的编辑确实突出了括号并显示匹配。问题是在#endif之后的最后一个支架。

 #ifndef PROYECTO_H
 #define PROYECTO_H

 #include<stdio.h>
 #include<stdlib.h>
 #include <fstream>
 #include <iostream>
 #include <string>
 #include <cassert>
 #include <cstddef>
using namespace std;
namespace lulz{
template<class T>
struct Contacto {
string Cname;
string Apellidos;
string NumTel;
string email;
T sexo;
Contacto *Proximo;
};

template<class T>
class Lista {
public:
Lista();
~Lista();
bool ContactoVacio();  
void InsertContact(Contacto<T> Temp);
void InsertPosition(Contacto<T> Temp, Contacto<T>* Posicion);
void BuscarContact(string Name, string Lastname);
Contacto<T>* BuscarPosicion(int pos);
void Display(ofstream& salida, Lista<T> Cabezalista);
void Deletes();
friend ofstream& operator << (ofstream&salida, const Lista<T>& Cabezalista){
Contacto<T>* ContactList;
int Pos=0;
for(ContactList = Cabezalista.Cabeza; (ContactList != NULL) && (ContactList-
>Proximo != NULL); ContactList = ContactList->Proximo)
 {
cout << ' ' << Pos+1 << ". " << ContactList->Cname << ' ' << ContactList-
>Apellidos << ' ';
cout << ContactList->NumTel << ' ' << ContactList->email << ' ' << 
ContactList->sexo << ' ' << endl;
   Pos++; 
}
cout << "Cantidad de nodos" << ' ' << Cabezalista.numNodos << endl;
return salida;
}
private:
Contacto<T>* Cabeza;
int numNodos;
};

template<class T>
ifstream& operator >>(ifstream& entrada, Contacto<T>& Temp);
template<class T>
bool Validacion(Contacto<T> Temp);
void Opening(ifstream& entrada);
void Closing(ifstream& entrada);
void Menu();
#endif // PROYECTO_H  
}

在我添加模板并添加了超载运算符的实现之前,它运行良好。我想念什么吗?

只需将#endif移至最后一个}