200bd0a8   
   From: crusader.mike@googlemail.com   
      
   On Oct 25, 1:10 pm, alejandro wrote:   
   > > Still, it is an omission in C++ -- why I can have this:   
   >   
   > > char const S1 = 'A';   
   > > char const S2 = S2;   
   >   
   > > or this:   
   >   
   > > char const S1[] = "AB";   
   > > char const S2[] = { S1[0], S1[1], S1[2] };   
   >   
   > > but cannot have this:   
   >   
   > > char const S1[] = "AB";   
   > > char const S2[] = S1;   
   > > ?   
   >   
   > Consider that   
   > char const S1[] = "AB";   
   >   
   > is something like   
   > char const Temp[] = {'A', 'B', '\0'};   
   > char const *S1 = new char[sizeof(Temp)];   
   > std::strcpy((char*)S1, Temp);   
      
   But it is not. "AB" gets placed in to data segment and referencing S1   
   means referencing address in memory where that segment was placed by   
   OS.   
      
      
   > While in   
   > char const S2[] = S1;   
   > the compiler cannot initialize S2 with a pointer   
      
   S1 is not a pointer. S1's type is 'char const[3]'. Implicit array-to-   
   pointer conversion is bad. :-)   
      
   Regards,   
   Michael.   
      
      
   --   
    [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
    [ comp.lang.c++.moderated. First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|