令牌之前的预期声明'}'
expected declaration before '}' token
我知道有额外的{或}时知道此错误消息。但是我的编辑确实突出了括号并显示匹配。问题是在#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
移至最后一个}
。
相关文章:
- 如何在C++中使用X509证书模在令牌中查找私钥
- holeMenuProgram.cpp:38:1 错误:'}'令牌之前的预期主表达式
- C++:"("令牌"之前有预期的非限定 id 指向类中成员函数的指针
- Arduino 用于语句错误。令牌之前的预期')' ';'。如何解决这个问题?
- 错误:令牌 { '{' 之前应存在非限定 ID
- 允许哪些令牌作为 #include 的参数?
- "错误 C0000:语法错误,令牌"<EOF>"处出现意外$end,并且不确定
- 它在 { 令牌之前给了我预期的标识符
- (错误:令牌之前'<<'预期的主表达式)
- 为什么 ## aka 令牌粘贴运算符不适用于 C 和 C++ 中的注释?
- 令牌之前的预期声明'}'
- 声明cudaError_t变量时出现无法识别的令牌错误
- 声明中的限定 ID 在"="令牌/对象计数器变量之前
- 3 错误:错误:未在此范围内声明'Entry'。错误:模板参数 1 无效。错误:令牌之前声明中的类型无效'('
- 令牌之前声明中的限定 ID '='
- C++ 模板类编译错误:令牌之前'<'预期的初始化声明器
- 令牌之前的预期声明说明符或'...' '*'
- 令牌之前声明中的限定 ID '('
- 错误:'vector'未命名类型/错误:'<'令牌之前的预期','或'...'/错误:尚未声明'vector'
- 使用未声明的标识符"令牌"