473,320 Members | 1,820 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Virtual Properties in MC++

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.
Nov 16 '05 #1
8 1524
Replace
return BaseClass::IntValue;
with
return BaseClass::get_IntValue();
or
return __super::get_IntValue();

Cheers,
Stoyan Damov

"Roy Chastain" <ro*@kmsys.com> wrote in message
news:41********************************@4ax.com...
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.

Nov 16 '05 #2
Hi Roy,

Thanks for your post!

Thanks for your feedback. I have reproduced it and am performing research
on it. I will get back here with more information as soon as possible.
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 <ro*@kmsys.com>
| Subject: Virtual Properties in MC++
| Date: Thu, 09 Oct 2003 11:56:49 -0400
| Organization: KMSystems, Inc.
| Reply-To: ro*@kmsys.com
| Message-ID: <41********************************@4ax.com>
| 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!TK2MSFTN GP10.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vc:29243
| X-Tomcat-NG: microsoft.public.dotnet.languages.vc
|
| 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.
|

Nov 16 '05 #3
Thanks, but should my syntax work correctly?

On Fri, 10 Oct 2003 13:42:29 +0300, "Stoyan Damov" <st*****@code.bg>
wrote:
Replace
return BaseClass::IntValue;
with
return BaseClass::get_IntValue();
or
return __super::get_IntValue();

Cheers,
Stoyan Damov

"Roy Chastain" <ro*@kmsys.com> wrote in message
news:41********************************@4ax.com.. .
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.
Nov 16 '05 #4
Well, it's up to Microsoft:) It's not C++. It's Managed C++:)

Cheers,
Stoyan

"Roy Chastain" <ro*@kmsys.com> wrote in message
news:4n********************************@4ax.com...
Thanks, but should my syntax work correctly?

On Fri, 10 Oct 2003 13:42:29 +0300, "Stoyan Damov" <st*****@code.bg>
wrote:
Replace
return BaseClass::IntValue;
with
return BaseClass::get_IntValue();
or
return __super::get_IntValue();

Cheers,
Stoyan Damov

"Roy Chastain" <ro*@kmsys.com> wrote in message
news:41********************************@4ax.com.. .
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.

Nov 16 '05 #5
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" <st*****@code.bg>
wrote:
Well, it's up to Microsoft:) It's not C++. It's Managed C++:)

Cheers,
Stoyan

"Roy Chastain" <ro*@kmsys.com> wrote in message
news:4n********************************@4ax.com.. .
Thanks, but should my syntax work correctly?

On Fri, 10 Oct 2003 13:42:29 +0300, "Stoyan Damov" <st*****@code.bg>
wrote:
>Replace
> return BaseClass::IntValue;
>with
> return BaseClass::get_IntValue();
>or
> return __super::get_IntValue();
>
>Cheers,
>Stoyan Damov
>
>"Roy Chastain" <ro*@kmsys.com> wrote in message
>news:41********************************@4ax.com.. .
>> 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.
Nov 16 '05 #6
Managed Extensions for C++ Specification

13.1 Scalar Properties

Constraint
There shall be only one scalar property declared in a single
scope with the same identifier. SCALAR PROPERTIES CANNOT BE OVERLOADED.

HTH,

Stoyan

"Roy Chastain" <ro*@kmsys.com> wrote in message
news:qh********************************@4ax.com...
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" <st*****@code.bg>
wrote:
Well, it's up to Microsoft:) It's not C++. It's Managed C++:)

Cheers,
Stoyan

"Roy Chastain" <ro*@kmsys.com> wrote in message
news:4n********************************@4ax.com.. .
Thanks, but should my syntax work correctly?

On Fri, 10 Oct 2003 13:42:29 +0300, "Stoyan Damov" <st*****@code.bg>
wrote:

>Replace
> return BaseClass::IntValue;
>with
> return BaseClass::get_IntValue();
>or
> return __super::get_IntValue();
>
>Cheers,
>Stoyan Damov
>
>"Roy Chastain" <ro*@kmsys.com> wrote in message
>news:41********************************@4ax.com.. .
>> 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.

Nov 16 '05 #7
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/de...us/vcmxspec/ht
ml/vcManagedExtensionsSpec_13.asp

"13.1 Scalar Properties"
http://msdn.microsoft.com/library/de...us/vcmxspec/ht
ml/vcManagedExtensionsSpec_13_1.asp

"13.2 Indexed Properties"
http://msdn.microsoft.com/library/de...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 <ro*@kmsys.com>
| Subject: Re: Virtual Properties in MC++
| Date: Fri, 10 Oct 2003 09:22:09 -0400
| Organization: KMSystems, Inc.
| Reply-To: ro*@kmsys.com
| Message-ID: <qh********************************@4ax.com>
| References: <41********************************@4ax.com>
<ue**************@TK2MSFTNGP10.phx.gbl>
<4n********************************@4ax.com>
<eW**************@TK2MSFTNGP12.phx.gbl>
| 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!TK2MSFTN GP11.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" <st*****@code.bg>
| wrote:
|
| >Well, it's up to Microsoft:) It's not C++. It's Managed C++:)
| >
| >Cheers,
| >Stoyan
| >
| >"Roy Chastain" <ro*@kmsys.com> wrote in message
| >news:4n********************************@4ax.com.. .
| >> Thanks, but should my syntax work correctly?
| >>
| >> On Fri, 10 Oct 2003 13:42:29 +0300, "Stoyan Damov" <st*****@code.bg>
| >> wrote:
| >>
| >> >Replace
| >> > return BaseClass::IntValue;
| >> >with
| >> > return BaseClass::get_IntValue();
| >> >or
| >> > return __super::get_IntValue();
| >> >
| >> >Cheers,
| >> >Stoyan Damov
| >> >
| >> >"Roy Chastain" <ro*@kmsys.com> wrote in message
| >> >news:41********************************@4ax.com.. .
| >> >> 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.
|

Nov 16 '05 #8
Well, it is now obvious to me that I am not smart enough to read MS
documentation.

Given the words that there can only be one definition in a scope and
that they (properties) can not be overloaded, I arrived at the
conclusion that the following was not valid.

__gc class dummy:
{
__property UInt32 VariableProperty (void)
{ return 4; }
__property String * VariableProperty (void)
{ return S"Abc"; }
};

I always thought that class produced a scope therefor having the same
name in two different classes was not violating the single instance
per scope rule and that since the definitions were the same in the two
classes they were not overloaded.

Now the scope is the assembly??

On Mon, 13 Oct 2003 07:39:44 GMT, v-******@online.microsoft.com (Gary
Chang [MSFT]) wrote:
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/de...us/vcmxspec/ht
ml/vcManagedExtensionsSpec_13.asp

"13.1 Scalar Properties"
http://msdn.microsoft.com/library/de...us/vcmxspec/ht
ml/vcManagedExtensionsSpec_13_1.asp

"13.2 Indexed Properties"
http://msdn.microsoft.com/library/de...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 <ro*@kmsys.com>
| Subject: Re: Virtual Properties in MC++
| Date: Fri, 10 Oct 2003 09:22:09 -0400
| Organization: KMSystems, Inc.
| Reply-To: ro*@kmsys.com
| Message-ID: <qh********************************@4ax.com>
| References: <41********************************@4ax.com>
<ue**************@TK2MSFTNGP10.phx.gbl>
<4n********************************@4ax.com>
<eW**************@TK2MSFTNGP12.phx.gbl>
| 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!TK2MSFTN GP11.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" <st*****@code.bg>
| wrote:
|
| >Well, it's up to Microsoft:) It's not C++. It's Managed C++:)
| >
| >Cheers,
| >Stoyan
| >
| >"Roy Chastain" <ro*@kmsys.com> wrote in message
| >news:4n********************************@4ax.com.. .
| >> Thanks, but should my syntax work correctly?
| >>
| >> On Fri, 10 Oct 2003 13:42:29 +0300, "Stoyan Damov" <st*****@code.bg>
| >> wrote:
| >>
| >> >Replace
| >> > return BaseClass::IntValue;
| >> >with
| >> > return BaseClass::get_IntValue();
| >> >or
| >> > return __super::get_IntValue();
| >> >
| >> >Cheers,
| >> >Stoyan Damov
| >> >
| >> >"Roy Chastain" <ro*@kmsys.com> wrote in message
| >> >news:41********************************@4ax.com.. .
| >> >> 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.
|


-------------------------------------------
Roy Chastain
KMSystems, Inc.
Nov 16 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: JPRoot | last post by:
Hi I use the following syntax to have events inherited from base to child classes which works nicely (virtual and override keyword on events). But I am wondering if it is a "supported" way of using...
2
by: Edward Diener | last post by:
In C++ an overridden virtual function in a derived class must have the exact same signature of the function which is overridden in the base class, except for the return type which may return a...
4
by: Edward Diener | last post by:
In MC++ properties are syntactically created through member functions declared with the __property keyword and using set_ and get_ naming conventions. Given that a property is specified in this...
2
by: Vladimir_petter | last post by:
Hello All, I've fount that if I compile the same program using gcc and vc 2003 the same class E (see complete source bellow) has different size (on vc it is 4 bytes bigger). Digging into this...
2
by: §iD` | last post by:
Hi! I would like to create a virtual folder (which I want to mount) and populate managing his content by a DLL or something like that in VB.NET (2.0). How can I acomplish this? Thanks to...
34
by: antonyliu2002 | last post by:
I've set up the virtual smtp server on my IIS 5.1 like so: 1. Assign IP address to "All Unassigned", and listen to port 25. 2. Access Connection granted to "127.0.0.1". 3. Relay only allow...
4
by: Just D. | last post by:
How can we change the property of one subdirectory of the Virtual Directory? One of the directories should be granted "Write". Should we delete this Virtual Directory to recreate it with the...
2
by: Rose winsle | last post by:
Hi guys ... I just wanted to create virtual directory using VB.net . i can manage that ... when i create the virtual directory how can i set anonymous access off. following is my code...
17
by: David C. Ullrich | last post by:
Having a hard time phrasing this in the form of a question... The other day I saw a thread where someone asked about overrideable properties and nobody offered the advice that properties are...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.