Hello,
I have a class with three overloaded indexed poperties.
Declaration in *.h
__gc class ByteArrayN : public FArrayN
{
typedef BYTE T;
typedef ByteArrayN FTArrayN;
.
.
__property T get_At(int ind1);
__property T set_At(int ind1,T value);
__property T get_At(int ind2,int ind1);
__property T set_At(int ind2,int ind1,T value);
__property T get_At(int ind3,int ind2,int ind1);
__property T set_At(int ind3,int ind2,int ind1,T value);
.
.
};
And in the *.cpp file
typedef ByteArrayN FTArrayN;
typedef BYTE T;
inline T FTArrayN::get_At(int ind1) { return ...}
inline T FTArrayN::set_At(int ind1,T value) {return ...}
inline T FTArrayN::get_At(int ind2,int ind1){return ...}
inline T FTArrayN::set_At(int ind2,int ind1,T value){return ...}
inline T FTArrayN::get_At(int ind3,int ind2,int ind1){return ...}
inline T FTArrayN::set_At(int ind3,int ind2,int ind1,T value){return ...}
inline FComplexN FTArrayN::GetFComplexAt(int ind3,int ind2,int ind1)
{
return (FComplexN)At[ ind3,ind2,ind1 ];
}
the above row At[ ind3,ind2,ind1 ] always call the function get_At[ ind 1 ].
The alternativ syntax At[ind3][ind2][ind1] works absolutly correct.
Is this a bug or am I wrong?
The language spec tell me, that both forms of syntax are allowed in MC++.
Michael Geier
"Gary Chang" - 17 Sep 2004 10:59 GMT
Hi Michael,
Currently I am looking for somebody who could help you on it. We will reply
here with more information as soon as possible.
If you have any more concerns on it, please feel free to post here.
Thanks for your understanding!
Best regards,
Gary Chang
Microsoft Online Partner Support

Signature
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
"Gary Chang" - 18 Sep 2004 03:39 GMT
Hi Michael,
> the above row At[ ind3,ind2,ind1 ] always call the function get_At[ ind 1 ].
According to the rules of C++ the above code is working as expected. C++
does have built-in support multi-dimensional arrays and thus a[e1, e2, e3]
is treated as a[(e1, e2, e3)], or once you apply the comma-expression rules
a[e3];
By the way, for Whidbey the compiler will be supporting multi-dimensional
CLR arrays and so with this release a[e1, e2, e3] will work the way the
user expects it to work.
Thanks!
Best regards,
Gary Chang
Microsoft Online Partner Support

Signature
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
Ronald Laeremans [MSFT] - 19 Sep 2004 21:01 GMT
Just to make sure we don't confuse readers:
> According to the rules of C++ the above code is working as expected. C++
> does have built-in support multi-dimensional arrays and thus a[e1, e2, e3]
> is treated as a[(e1, e2, e3)], or once you apply the comma-expression
> rules
> a[e3];
Gary meant to say that C++ does __NOT__ have built in rectangular
multi-dimensional arrays.
And if anyone is less familiar with the comma operator, it evaluates all
arguments left to right and then returns the last one.
Thanks.
Ronald Laeremans
Visual C++ team
> Hi Michael,
>
[quoted text clipped - 21 lines]
> rights.
> --------------------
Sally Lou [MSFT] - 20 Sep 2004 15:25 GMT
Hi, Michael:
Here is what I have found out from the book <<Essential Guide to Managed
Extenstions for C++>> by Siva Challa:
A good property behaves like a data member. But there is things that we can
do with a data member but not with a property.
"An array property declaration shall not overload an indexed property."
Otherwise, we will have ambiguity problem.
It looks from your code, you have overloaded the array property. I would
suggest you to avoid overloading here.
Thanks!
Sally Lou
This posting is provided "AS IS" with no warranties, and confers no rights.