On 21 Mar 01, at 19:53, Maurice Lombardi wrote:
You are right of course. But that is still one of the "gotchas" that one needs to bear in mind, although it is a different one from the one that I had in mind at the time. And furthermore you cannot then be sure that there are no memory leaks - you have constructed two objects and allocated memory and resources for both of them, and you are only freeing one of them. That sounds like a memory leak to me, unless I am missing something.
Right, but it is a programming error the way the program has been written. The correct way would be to free h1 before assigning it a new value, or to keep the corresponding address in an other pointer, otherwise the location it was pointing to before the affectation is lost.
Of course ...
But this is of no consequence on the original issue.
Correct. The original issue is how the compiler would know at compile time what the type of an object is so as to generate a compile-time error with "is" and "as", and my original example was only for the purpose of demonstrating that it is easy for the compiler to know this, and that, indeed, it should know this. But then we all went off on other tangents ...
An old Chinese saying: "do not go off on a tangent, because tangents can bite you" (actually, I just made that up ;)).
Best regards, The Chief -------- Prof. Abimbola A. Olowofoyeku (The African Chief) Author of: Chief's Installer Pro for Win32 http://www.bigfoot.com/~African_Chief/chief32.htm Email: African_Chief@bigfoot.com