javanic
asked on
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->myC lass->ToSt ring(), S"explicit call to ToString()");
MessageBox::Show(this->myC lass, S"implicit call to ToString()");
TIA,
javanic
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->myC
MessageBox::Show(this->myC
TIA,
javanic
ASKER
Hmmm. I was hoping there was something in Managed C++ that allowed something like VB.NET default property. See http://abstractvb.com/code.asp?A=1036. I believe C# also allows that functionality. Consider the Item property--which is the default property/method of a collections class. See: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbtskChoosingDefaultPropertyOrMethodForClass.asp
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... :)
javanic
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... :)
javanic
ASKER
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++:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemcomponentmodeldefaultpropertyattributeclasstopic.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemcomponentmodeldefaultpropertyattributeclasstopic.asp
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You can read about managed C++ operators at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmxspec/html/vcManagedExtensionsSpec_20.asp.