Things are not as nice in the situations in which the Delphi 2009 compiler ends up calling a different method that you'd expect from previous versions. This is an extremely rare circumstance, but it is technically possible (even if in some convoluted cases).
Consider the following code (part of the VariantOver example), declaring a record type with an Implicit conversion:
TMyRecord = record private
X: Integer; publ ic class operator Implicit (
const Value: Variant): TMyRecord;
Now suppose you have two overloaded methods taking either a record or an Integer parameter:
procedure showVa1ue3 (const R: TMyRecord); overload; procedure ShowVa1ue3 (x: Integer); overload;
What happens if you pass a variant? The compiler can either convert the variant to the Integer or use the Implicit operation to convert it to a record. This is the call :
var v: Variant; begi n v := 10; ShowVa1ue3 (v); end ;
What happens is that in Delphi 2007 this code calls the Integer overload, while Delphi 2009 compiler gives precedence to the Implicit overload.
Was this article helpful?
What you need to know about… Project Management Made Easy! Project management consists of more than just a large building project and can encompass small projects as well. No matter what the size of your project, you need to have some sort of project management. How you manage your project has everything to do with its outcome.