Re: Static Read-only array fields in C++
From: Tomas Restrepo \(MVP\) (tomasr_at_mvps.org)
Date: 08/31/04
- Next message: Kluch: "Re: Calling a managed __gc class from a mixed mode dll, please he"
- Previous message: ScottD: "one-step build for hello.c"
- In reply to: Mark Dunmill: "Re: Static Read-only array fields in C++"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 30 Aug 2004 22:09:21 -0500
Hi Mark,
> Thanks fior the reply. I had already suspected that this was impossible in
> C++ .NET 2003.
>
> Just to clarify, this appears only to be a problem relating to managed
> arrays. With other types of objects, the 'const' keyword in the
appropriate
> place seems to do what I want. (The object is still mutable but the
'pointer'
> isn't.)
> If not using arrays, does the 'const' keyword actually result in the
correct
> 'initonly' entry in the metadata, or is it just 'const' as far as the C++
> compiler is concerned but external consumers of this class, implemented in
> different languages, would actually be able to modify this public field.
It depends on where you put it :)
Example, this:
static String * const empty = S"asdasd";
will generate "initonly". This, otoh:
static const String * empty = S"asdasd";
won't :)
> Also, any idea why this is an issue with managed arrays, and not other
> managed type in C++? Is this just a quirk with the way the managed array
> syntax was implemented in Managed C++?
I'm not quite sure exactly what the issue is, someone from MS would've to
chime in to answer exactly... It's probably a quirk in the front end, I
guess....
-- Tomas Restrepo tomasr@mvps.org
- Next message: Kluch: "Re: Calling a managed __gc class from a mixed mode dll, please he"
- Previous message: ScottD: "one-step build for hello.c"
- In reply to: Mark Dunmill: "Re: Static Read-only array fields in C++"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|