Board index » cppbuilder » Default Property

Default Property


2005-05-22 04:20:49 PM
cppbuilder0
Does BCB supports default property in a class?
 
 

Re:Default Property

"tinyabs" < XXXX@XXXXX.COM >wrote in message
Quote
Does BCB supports default property in a class?
Not in C++ code, no. That is a Delphi-only feature.
The only thing that comes close is BCB6's support for subscript operators
that map to default properties internally. For example, the Strings[]
property is the default property for the TStrings class. Instead of writing
'Strings1->Strings[i]', you can write '(*Strings1)[i]' instead. Not exactly
the same thing that Delphi does with default properties, but the closest
that C++ is going to get to it. Of course, if you are writing your own C++
classes, you can implement your own subscript operators manually regardless
of compiler version.
Gambit
 

Re:Default Property

I check the code declaration and found this.
AnsiString operator[](int Index) { return Strings[Index]; }
As I suspected, it overrides operator[] to accomplish it.
 

{smallsort}