In article <t7***************@newssvr11.news.prodigy.com>,
red floyd <no*****@here.dudewrote:
>Frederick Gotham wrote:
>What are your thoughts on the following code?
typedef int Coords[3];
int main()
{
Coords *const p = new Coords;
delete p;
}
It doesn't compile with g++ on my system, saying:
cannot convert `int*' to `int (* const)[3]' in initialization
Half of me thinks that Coords is just an array in disguise and that the error
is justified, and the other half thinks that Coords is a new fully-fledged
type and that the code should be OK.
Not sure, but Comeau online doesn't like it either, for pretty much the
same reason.
Remember new does not return a pointer to the whole memory
just to the first element. IOWs, for new int, it returns
an int *, and for a new int[3] it still returns an int *,
but p is an int (*const)[3]
--
Greg Comeau / 20 years of Comeauity! Intel Mac Port now in alpha!
Comeau C/C++ ONLINE ==
http://www.comeaucomputing.com/tryitout
World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?