implicit or default method/property of a class

Hi all,

Is there a way to create an implicit or default method or property of a class in Managed C++?

In other words, how do I declare a ToString method so that the two statements below both call the ToString method?
  MessageBox::Show(this->myClass->ToString(), S"explicit call to ToString()");
  MessageBox::Show(this->myClass, S"implicit call to ToString()");


Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I cannot think of a way to do this.  The Show method wants a String* parameter so a conversion needs to be done.  Unfortunately, user-defined operators are not invoked on pointer types in C++.  This means that you'd have explicitly call the conversion operator which is no better than having to explicitly call ToString().

You can read about managed C++ operators at
javanicAuthor Commented:
Hmmm. I was hoping there was something in Managed C++ that allowed something like VB.NET default property. See I believe C# also allows that functionality. Consider the Item property--which is the default property/method of a collections class. See:

By the way, I just found the reference to the C# functionality, though I knew it existed. I was hoping it existed in MC++ and that someone would have a reference to it... :)

javanicAuthor Commented:
In case anyone is following this thread, I think I have found what I was looking for. Here is the reference to a default property declaration for Managed C++:

You can try it, but I don't believe a default property will give you the functionality you are looking for.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual C++.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.