| 
 | |||||||
| 
 | 
|  | 
|  | 
|  | Strumenti | 
|  02-07-2008, 15:44 | #1 | 
| Junior Member Iscritto dal: Jul 2008 
					Messaggi: 3
				 | 
				
				[C++] Implementazione variabile con enum
			 
		string i = "ciao"; TextToken c = new TextToken(li2::TextToken::Word, i); io devo implementare c ma scrivendo così mi da questo errore: ..\texAnalyzer_main.cpp conversion from `li2::TextToken*' to non-scalar type `li2::TextToken' requested La classe di riferimento è questa: class TextToken { public: // TextToken::Type: elenco dei tipi token di interesse enum Type { Word, // parola SpaceSequence, // sequenza di spazi PunctuationMark // simbolo di punteggiatura } ; // TextToken::TextToken: costruttore parametrico // permette di costruire un oggetto TextToken a partire dal tipo e dal // valore del token // Il valore di un token è la sequenza di caratteri che lo compongono TextToken(Type type, const string &value) : mTtype(type), mValue(value) {} Type mTtype; string mValue; }; /*------------------------------------------------------------------------------ class TextLine Rappresenta una linea di testo La linea di testo è rappresentata mediante la sequenza di TextToken in essa contenuti -----------------------------------------------------------------------------*/ class TextLine { public: // TextLine::TextLine: costruttore parametrico // Costruisce un oggetto TextLine a partire da una stringa // L'implementazione del costruttore suddivide la stringa text nella // sequenza di token che la compongono TextLine(const string &text); // costruttore di copia TextLine(const TextLine &textline); // distruttore ~TextLine(); // operatore di assegnazione TextLine &operator=(const TextLine &textline); // TextLine::getText // restituisce il testo della linea composto a partire dalla giustapposizione dei token // contentuti nella linea di testo string getText(); // TextLine::getTokenCount // restituisce il numero di token nella linea di testo size_t getTokenCount() const; // TextLine::getToken // restituisce l'i-esimo token nella linea di testo TextToken *getToken(size_t i) const; private: // mTokens contiene la sequenza di TextToken che compongono la linea di testo vector<TextToken *> mTokens; }; Grazie anticipatamente!!! | 
|   |   | 
|  02-07-2008, 16:57 | #2 | 
| Senior Member Iscritto dal: Jun 2002 Città: Dublin 
					Messaggi: 5989
				 | 
		L'operatore new sulle classi crea un nuovo oggetto e te ne restituisce il puntatore. In altre parole, hai sbagliato la dichiarazione: Codice: TextToken *c = new TextToken(...); 
				__________________ C'ho certi cazzi Mafa' che manco tu che sei pratica li hai visti mai! | 
|   |   | 
|   | 
| Strumenti | |
| 
 | 
 | 
Tutti gli orari sono GMT +1. Ora sono le: 16:54.









 
		 
		 
		 
		






 
  
 



 
                        
                        










