|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Senior Member
Iscritto dal: May 2006
Città: Wursteland
Messaggi: 1749
|
[C++] return NULL == return string ???
Ho fatto questa funzione ma toppando, non volevo ritornare un oggetto string (dannato copia incolla
Però il g++ non mi da errore Che senso ha tornare un NULL quando la funzione dovrebbe tornare un oggetto ? non dovrebbe essere un errore (e pure brutto) ? Codice:
string LLConfigFile::SearchLine(const string& sSearch)
{
...
return NULL;
}
__________________
Nintendo WIII 4d Turbo Intercooler - Sestium X 666 99,312 GHz - 6.984 Ram Σ(9999) MHz - HDD SATA 97e^(10) bytes 93³ rpm - ATI biberon X900z ∞Mb - Win Eight SP (1 > yours) 16 Valve |
|
|
|
|
|
#2 |
|
Senior Member
Iscritto dal: Oct 2006
Città: Roma
Messaggi: 1383
|
stai implicitamente invocando un costruttore di string, quello che vuole un argomento di tipo puntatore; trattasi del costruttore che prende un puntatore a char, lo legge come stringa null-terminated e costruisce l'oggetto relativo.
la documentazione del costruttore dice che quella versione del costruttore non accetta NULL, quindi a runtime dovresti ottenere qualche errore. |
|
|
|
|
|
#3 |
|
Senior Member
Iscritto dal: May 2006
Città: Wursteland
Messaggi: 1749
|
Dici che secondo "lui" io sto facendo un string(NULL) ?
Boh, io lo segnalerei come errore piuttosto che implicitamente invocare ...
__________________
Nintendo WIII 4d Turbo Intercooler - Sestium X 666 99,312 GHz - 6.984 Ram Σ(9999) MHz - HDD SATA 97e^(10) bytes 93³ rpm - ATI biberon X900z ∞Mb - Win Eight SP (1 > yours) 16 Valve |
|
|
|
|
|
#4 | ||
|
Senior Member
Iscritto dal: Oct 2006
Città: Roma
Messaggi: 1383
|
Quote:
Quote:
|
||
|
|
|
|
|
#5 | |
|
Senior Member
Iscritto dal: May 2006
Città: Wursteland
Messaggi: 1749
|
Quote:
__________________
Nintendo WIII 4d Turbo Intercooler - Sestium X 666 99,312 GHz - 6.984 Ram Σ(9999) MHz - HDD SATA 97e^(10) bytes 93³ rpm - ATI biberon X900z ∞Mb - Win Eight SP (1 > yours) 16 Valve |
|
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 05:30.




















