2017-06-04 114 views
-2

我知道從何時有一個額外的{}或此錯誤消息。但我的編輯確實突出了括號並顯示它匹配。問題出在#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 
} 

它運行良好之前我增加了模板和添加的重載運算符< <的實施。我錯過了什麼嗎?

+0

當你'#include'文件會發生什麼呢?或者,以另一種方式提出問題,如果將問題'}放在'#endif'之前會發生什麼? –

+1

那麼,什麼是支架'#endif'之後在那裏做什麼??? – AnT

+0

我已經試過了,我得到了很多樣T誤差在此範圍內未聲明,模板參數1無效,不能轉換「lulz :: CONTACTO <性病:: basic_string的......爲int *在assingment。到目前爲止,我一直都是這樣對待我的過去,並一直工作。 – acarana

回答

1

只需推動#endif最後}後。