Topic: delete'ing a pointer to const
Author: Rey Crisostomo <reynaldoc@vnet.ibm.com>
Date: 1997/01/28 Raw View
Fergus Henderson wrote:
>
> "Rey Crisostomo" <rey@clear.net.nz> writes:
>
> >In the latest draft, is it an error to delete a pointer to const?
>
> No. That was made legal in November 94.
>
> >For example,
> >
> >const A *a = new A;
> >...
> >delete a;
> >
> >Should the above example compile?
>
> Yes, it should.
>
Does this mean that I should be able to do this:
{
auto_ptr<const A> aptr(new A);
...
}
Here, A is a previously define class and auto_ptr is the
standard C++ auto_ptr class defined in the header <memory>.
---
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Author: fjh@mundook.cs.mu.OZ.AU (Fergus Henderson)
Date: 1997/01/28 Raw View
Rey Crisostomo <reynaldoc@vnet.ibm.com> writes:
>Does this mean that I should be able to do this:
>
>{
> auto_ptr<const A> aptr(new A);
> ...
>}
>
>Here, A is a previously define class and auto_ptr is the
>standard C++ auto_ptr class defined in the header <memory>.
Yes, that should be fine.
--
Fergus Henderson <fjh@cs.mu.oz.au> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger fjh@128.250.37.3 | -- the last words of T. S. Garp.
---
[ comp.std.c++ is moderated. To submit articles: Try just posting with your
newsreader. If that fails, use mailto:std-c++@ncar.ucar.edu
comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
Comments? mailto:std-c++-request@ncar.ucar.edu
]
Author: "Rey Crisostomo" <rey@clear.net.nz>
Date: 1997/01/24 Raw View
In the latest draft, is it an error to delete a pointer to const? For
example,
const A *a = new A;
...
delete a;
Should the above example compile?
--
Rey Crisostomo
Wellington, New Zealand
rey@clear.net.nz
reynaldoc@vnet.ibm.com
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Author: fjh@mundook.cs.mu.OZ.AU (Fergus Henderson)
Date: 1997/01/25 Raw View
"Rey Crisostomo" <rey@clear.net.nz> writes:
>In the latest draft, is it an error to delete a pointer to const?
No. That was made legal in November 94.
>For example,
>
>const A *a = new A;
>...
>delete a;
>
>Should the above example compile?
Yes, it should.
--
Fergus Henderson <fjh@cs.mu.oz.au> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger fjh@128.250.37.3 | -- the last words of T. S. Garp.
---
[ comp.std.c++ is moderated. To submit articles: Try just posting with your
newsreader. If that fails, use mailto:std-c++@ncar.ucar.edu
comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
Comments? mailto:std-c++-request@ncar.ucar.edu
]