Pages: [1]   Go Down
Author Topic: There should be more const methods in String  (Read 715 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 23
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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);
  }

 smiley-sad



Logged

Pages: [1]   Go Up
Jump to: