|
From: Hendrik Schober on 28 Apr 2008 04:20 Jim Johnson <aopiyy001(a)yahoo.com> wrote: > The following line is illegal? > std::string line = NULL; > // for a value I cannot set to null as it's not an address Yes. It initializes a 'std::string' with the 'NULL' pointer. While the 'NULL' pointer is a valid 'const char*', and you can initialize 'std::string' with 'const char*', you must not initialize 'std::string' with 'NULL', as its constructor doesn't check for 'NULL'. If you want an empty string, just write std::string line; > Then I should write like following? > std::string * line = NULL; // a pointer I can set to null pointer This is something completly different. It creates a pointer that points to address 'NULL'. Schobi (F'up) -- SpamTrap(a)gmx.de is never read I'm HSchober at gmx dot de "I guess at some point idealism meets human nature and explodes." Daniel Orner
First
|
Prev
|
Pages: 1 2 Prev: Increasing your traffic and rankings to your website... Next: pointer non-pointer |