Go Down

Topic: There should be more const methods in String (Read 761 times) previous topic - next topic

vesal

F.ex

void String::toCharArray(char *buf, unsigned int bufsize)

and

void String::getBytes(unsigned char *buf, unsigned int bufsize)

are not const methods as they should be.

And because they are not const methods like

void String::toCharArray(char *buf, unsigned int bufsize) const

on can not call toCharArray from method like

 write(const String &str) {
         int n = s.length()+1;
         char sc[n];
         s.toCharArray(sc,n);
         write(sc);
 }

:(




Go Up