Good :) So MC++ is the best .NET language ;) 

Cheers,
Stoyan 

-----Original Message-----
From: Unmoderated discussion of advanced .NET topics.
[mailto:[EMAIL PROTECTED] On Behalf Of Bogdan
Lachendro
Sent: Friday, November 19, 2004 5:02 PM
To: [EMAIL PROTECTED]
Subject: Re: [ADVANCED-DOTNET] const modifier in method parameter -
managed c++


On 2004-11-19 15:51, Stoyan Damov wrote:
> I think that my previous post could answer the question - so you can 
> consume both methods from a managed C++ client? If the IL is same for 
> both methods, then at least Microsoft should have added a 
> HideFromNonMcppCompilers (or something like this) to the method as 
> well, so non-MC++ clients cannot see the "offending" method.

I have changed the code to :

        public __gc class MyClass
        {
     public:

         void foo(MyClass* const a)
         {
             System::Console::WriteLine("void foo(MyClass* const a)");
         }

         void foo(const MyClass* a)
         {
             System::Console::WriteLine("void foo(const MyClass* a)");
         }

         void boo()
         {
             const MyClass* myClass;
             this->foo(myClass);
         }

         void boo1()
         {
             MyClass* const myClass = 0;
             this->foo(myClass);
         }

        };

Then created C# executable with main:

             MyClass a = new MyClass();
             a.boo();
             a.boo1();

The output is:

void foo(const MyClass* a)
void foo(MyClass* const a)

The IL code for those methods differ only by method tokens.

B.


>
> -----Original Message-----
> From: Unmoderated discussion of advanced .NET topics. 
> [mailto:[EMAIL PROTECTED] On Behalf Of Bogdan 
> Lachendro
> Sent: Friday, November 19, 2004 4:48 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [ADVANCED-DOTNET] const modifier in method parameter - 
> managed c++
>
>
> On 2004-11-19 15:41, Stoyan Damov wrote:
>
>>Are you new to .NET? AFAIK no .NET-enabled language except C++ 
>>supports object const-ness. It is interesting though that you managed 
>>to compile the class with the MC++. In .NET (as opposed to C++, where 
>>const rules) you'll have to learn to deal with readonly (initonly) 
>>fields, get/set properties, read-only collections (or similar
>>patterns) to prevent object clients to modify the instance, etc., etc.
>
>
>>IMHO losing const is a drawback but this has been discussed many times
>
>
>>and I don't want to start any religious wars.
>
>
> Maybe I wasn't clear enough. Or perhaps I should make the question 
> different. I wonder why the MC++ compiler allows the constructs as 
> below and generates the same IL code for both of the methods.
>
> Regards,
> Bogdan
>
>
>>-----Original Message-----
>>From: Unmoderated discussion of advanced .NET topics. 
>>[mailto:[EMAIL PROTECTED] On Behalf Of Bogdan 
>>Lachendro
>>Sent: Friday, November 19, 2004 4:11 PM
>>To: [EMAIL PROTECTED]
>>Subject: [ADVANCED-DOTNET] const modifier in method parameter - 
>>managed
>>c++
>>
>>
>>Hi,
>>
>>Lets say I have a  class:
>>
>>        public __gc class MyClass
>>        {
>>     public:
>>
>>         void foo(MyClass* const a)
>>         {
>>         }
>>
>>         void foo(const MyClass* a)
>>         {
>>         }
>>        };
>>
>>Why is the IL code generated by MVC++ the same for both those methods?
>
>
>>Is there any way to use such method in C# code? Currently I have:
>>
>>e:\classlibrary1\class1.cs(34,13): error CS0121: The call is ambiguous
>
>
>>between the following methods or properties: 
>>'ManagedClass.MyClass.foo(ManagedClass.MyClass)' and 
>>'ManagedClass.MyClass.foo(ManagedClass.MyClass)'
>>
>>Thanks,
>>
>>Regards,
>>Bogdan
>>
>>===================================
>>This list is hosted by DevelopMentorŽ  http://www.develop.com Some 
>>.NET courses you may be interested in:
>>
>>Essential .NET: building applications and components with C# November 
>>29
>>- December 3, in Los Angeles http://www.develop.com/courses/edotnet
>>
>>View archives and manage your subscription(s) at 
>>http://discuss.develop.com
>>
>>===================================
>>This list is hosted by DevelopMentorŽ  http://www.develop.com Some 
>>.NET courses you may be interested in:
>>
>>Essential .NET: building applications and components with C# November 
>>29 - December 3, in Los Angeles http://www.develop.com/courses/edotnet
>>
>>View archives and manage your subscription(s) at 
>>http://discuss.develop.com
>>
>>
>
>
>
> --
> Bogdan Lachendro                         mailto:lachu(at)poczta.fm
> http://www.the.king.of.pl TEL +48606318657 UIN 66844735 GG 1469796
>          A wise man changes his mind, a fool never will...
>
> ===================================
> This list is hosted by DevelopMentorŽ  http://www.develop.com Some 
> .NET courses you may be interested in:
>
> Essential .NET: building applications and components with C# November 
> 29
> - December 3, in Los Angeles http://www.develop.com/courses/edotnet
>
> View archives and manage your subscription(s) at 
> http://discuss.develop.com
>
> ===================================
> This list is hosted by DevelopMentorŽ  http://www.develop.com Some 
> .NET courses you may be interested in:
>
> Essential .NET: building applications and components with C# November 
> 29 - December 3, in Los Angeles http://www.develop.com/courses/edotnet
>
> View archives and manage your subscription(s) at 
> http://discuss.develop.com
>
>


--
Bogdan Lachendro                         mailto:lachu(at)poczta.fm
http://www.the.king.of.pl TEL +48606318657 UIN 66844735 GG 1469796
         A wise man changes his mind, a fool never will...

===================================
This list is hosted by DevelopMentorŽ  http://www.develop.com Some .NET
courses you may be interested in:

Essential .NET: building applications and components with C# November 29
- December 3, in Los Angeles http://www.develop.com/courses/edotnet

View archives and manage your subscription(s) at
http://discuss.develop.com

===================================
This list is hosted by DevelopMentorŽ  http://www.develop.com
Some .NET courses you may be interested in:

Essential .NET: building applications and components with C#
November 29 - December 3, in Los Angeles
http://www.develop.com/courses/edotnet

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to