Hi Roy,
Have you read Stoyen's reply? It's really the key to your question.
Since the runtime property is a new concept to Managed C++, The Managed
Extensions provide a mechanism to write and import a class that contains a
common language runtime property, you can write 2 kinds of properties:
Scalar Property and Indexed Property.
The property used in your code is Scalar Property, there shall be only one
scalar property declared in a single scope with the same identifier and the
Scalar properties cannot be overloaded. For this reason, the complier can
only recognize the "__property virtual int get_IntValue (void)" definition
of the DerivedClass in the whole app's scope and ignores the previous one
defined in the BaseClass. So when "return BaseClass::IntValue" is executed
in the
DerivedClass:__property virtual int get_IntValue (void){...}, it just call
himself recursively,
results infinite loop and call stack overflow finally.
You can find more detailed information about the Property in Managed C++:
"13 Properties"
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmxspec/ht
ml/vcManagedExtensionsSpec_13.asp
"13.1 Scalar Properties"
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmxspec/ht
ml/vcManagedExtensionsSpec_13_1.asp
"13.2 Indexed Properties"
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmxspec/ht
ml/vcManagedExtensionsSpec_13_2.asp
Hope it helps!
Gary Chang
Microsoft Online Partner Support
Get Secure! –
www.microsoft.com/security
This posting is provided "AS IS" with no warranties,and confers no rights.
--------------------
| From: Roy Chastain <
[email protected]>
| Subject: Re: Virtual Properties in MC++
| Date: Fri, 10 Oct 2003 09:22:09 -0400
| Organization: KMSystems, Inc.
| Reply-To: (e-mail address removed)
| Message-ID: <
[email protected]>
| References: <
[email protected]>
<
[email protected]>
<
[email protected]>
<
[email protected]>
| X-Newsreader: Forte Agent 1.92/32.572
| MIME-Version: 1.0
| Content-Type: text/plain; charset=us-ascii
| Content-Transfer-Encoding: 7bit
| Newsgroups: microsoft.public.dotnet.languages.vc
| NNTP-Posting-Host: 66.20.246.162
| Lines: 1
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vc:29275
| X-Tomcat-NG: microsoft.public.dotnet.languages.vc
|
| I agree, let me rephrase my question.
|
| Is there anything in the doc that would indicate that my syntax should
| not work or that your syntax is the only one that should work?
|
| On Fri, 10 Oct 2003 16:15:11 +0300, "Stoyan Damov" <
[email protected]>
| wrote:
|
| >Well, it's up to Microsoft
It's not C++. It's Managed C++
| >
| >Cheers,
| >Stoyan
| >
| >| >> Thanks, but should my syntax work correctly?
| >>
| >> On Fri, 10 Oct 2003 13:42:29 +0300, "Stoyan Damov" <
[email protected]>
| >> wrote:
| >>
| >> >Replace
| >> > return BaseClass::IntValue;
| >> >with
| >> > return BaseClass::get_IntValue();
| >> >or
| >> > return __super::get_IntValue();
| >> >
| >> >Cheers,
| >> >Stoyan Damov
| >> >
| >> >| >> >> I have tried this on a couple of occasions and each time the
resulting
| >> >> program goes into a loop and eventually gets a stack overflow.
| >> >>
| >> >> public __gc BaseClass {
| >> >> __property virtual int get_IntValue (void)
| >> >> { return 3; }
| >> >> };
| >> >>
| >> >> public __gc DerivedClass: public BaseClass {
| >> >> __property virtual int get_IntValue (void)
| >> >> { return BaseClass::IntValue; }
| >> >> };
| >> >>
| >> >> .......calling code.....
| >> >>
| >> >> DerivedClass *loop = new DerivedClass();
| >> >> loop->IntValue;
| >> >>
| >> >> Anyone know if I am doing this wrong or if the compiler etc is
broken?
| >> >>
| >> >> Thanks
| >> >>
| >> >> -------------------------------------------
| >> >> Roy Chastain
| >> >> KMSystems, Inc.
| >> >
| >>
| >> -------------------------------------------
| >> Roy Chastain
| >> KMSystems, Inc.
| >
|
| -------------------------------------------
| Roy Chastain
| KMSystems, Inc.
|