Mail Archives: djgpp/2001/05/03/12:30:40
Rafal Maj <maj_rafal AT poczta DOT onet DOT pl> wrote:
> So both delete s; and delete[] s; are wrong ? I know that delete is C++
> style, but since char* has no destructor, I think that delete or delete[]
> will work for this type same as free(). Am I right ?
Unfortunately not. Perhaps there is no impact in DJGPP, but the standard
forbids this.
Bjarne Stroustrup ('The C++ Programming Language') (no exact wording):
Allocating a pointer using new or new[] and deallocating it using
free() is asking for trouble.
Of course the other way round is not ok either.
If it works depends on your C++ library; if the new and delete operators
call malloc and free, what you are trying to do is safe. If not, it will
make trouble. So: do not do this!
--
#!/usr/bin/perl -w -- sequences
$0=++$|;for(;;){print-length$0;$0=~s/(.)\1*/$1.length$&/ge;}print"\n";
- Raw text -