Ecere SDK/eC Forums http://ec-lang.org/community/ Print view |
|
property what? http://ec-lang.org/community/viewtopic.php?f=1&t=210 |
Page 1 of 1 |
Author: | samsam598 [ Thu Jan 12, 2012 8:48 pm ] |
Post subject: | property what? |
Greetings! From explorer example below,I was completely confused for property char * which has no any identifier here,is it a anoynmous property or something else? Thanks for your clarification. Code: Select all
|
Author: | jerome [ Thu Jan 12, 2012 10:42 pm ] |
Post subject: | Re: property what? |
Hi Sam! Welcome back! We really missed you here!! The forums were so quiet without you I will answer you in more details tomorrow, but just to get you started on this, these are 'conversion properties'. See chapter on page 100 in the Tao They are 'somewhat' akin to 'operator String' in C++. I'll get back to you tomorrow! Cheers, Jerome |
Author: | samsam598 [ Thu Jan 12, 2012 11:32 pm ] |
Post subject: | Re: property what? |
Thanks Jerome,I am always here actually.But it is crazy busy recently as the Chinese New Year is coming.*_* Acutally I have tons of stupid questions but shame to ask ..he he. Regards, Sam |
Author: | jerome [ Sun Jan 15, 2012 12:30 am ] |
Post subject: | Re: property what? |
Hi again Sam, Yes quite crazy here also! We are leaving on Saturday for Vietnam to celebrate the new year with my wife's family as well So, just to clarify, a property with only a type, and no name, is a conversion property. This makes it possible to convert the class (and vice-versa) to the data type whose conversion is being defined by the property. This is particularly useful with units, as it lets you establish a relationship. This relationship is then automatically used for anywhere a conversion is required, and serves the purpose of operator-overloading (on scalar types only. operator overloading would still be useful on things like vectors, matrices!). So in your example, that property is just to allow to write: QuickPathTool quickPathTool { }; char * string = quickPathTool; or quickPathTool = "whatever a quickpath string representation is"; Please let me know if you have any more question about these The Tao chapter I previously mentioned covers it quite well, and the most interesting use really is for unit conversions, which is not what your example was about. Regards, Jerome |
All times are UTC-05:00 | Page 1 of 1 |
Powered by phpBB® Forum Software © phpBB Limited |