Go Down

Topic: There should be more const methods in String (Read 786 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
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy