On Fri, Feb 20, 2009 at 12:34 PM, Christian Plesner Hansen <
[email protected]> wrote:

> Surely you jest.



 #include <string.h>
#include <stdio.h>

class OS {
 public:
  static const char* strchr(const char* haystack, char needle);
  static char* strchr(char* haystack, char needle);
};

int main(char** argv, int argc) {
  const char* foo = "foo";
  char* bar = new char[4];
  strcpy(bar, "bar");
  const char* f = OS::strchr(foo, 'f');
  char * b = OS::strchr(bar, 'b');
  printf("%s, %s\n", f, b);
}


>
> On Fri, Feb 20, 2009 at 12:32 PM, Erik Corry <[email protected]> wrote:
> >
> >
> > On Fri, Feb 20, 2009 at 12:31 PM, <[email protected]> wrote:
> >>
> >>
> >> http://codereview.chromium.org/20534/diff/1/7
> >> File src/platform.h (right):
> >>
> >> http://codereview.chromium.org/20534/diff/1/7#newcode222
> >> Line 222: static char* StrChr(const char* str, int c);
> >> Good point removed const from the argument.
> >>
> >> On 2009/02/20 11:20:09, Christian Plesner Hansen wrote:
> >> > Consider making the argument non-const.  I've been bitten by passing a
> >> string
> >> > that shouldn't be modified into strchr and then modifying the result
> >> -- the
> >> > error on windows was what alerted me to it.
> >
> > Surely in C++ you could have both (overloading).
> >
> >>
> >> http://codereview.chromium.org/20534
> >>
> >> > >>
> >
> >
> >
> > --
> > Erik Corry, Software Engineer
> > Google Denmark ApS.  CVR nr. 28 86 69 84
> > c/o Philip & Partners, 7 Vognmagergade, P.O. Box 2227, DK-1018 Copenhagen
> K,
> > Denmark.
> >
>



-- 
Erik Corry, Software Engineer
Google Denmark ApS.  CVR nr. 28 86 69 84
c/o Philip & Partners, 7 Vognmagergade, P.O. Box 2227, DK-1018 Copenhagen K,
Denmark.

--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to