Re: [fpc-pascal] Cast, inheritance, etc

2012-12-05 Thread Chad Berchek
This is an example of why it is usually wise to use the AS operator except in performance critical places. Using the parentheses notation is an unsafe cast; type checking does not occur at the time of the cast. This is especially dangerous because you run the risk of corrupting memory by writin

Re: [fpc-pascal] Cast, inheritance, etc

2012-12-04 Thread silvioprog
2012/12/4 Marcos Douglas > On Tue, Dec 4, 2012 at 4:53 PM, Sven Barth > wrote: > > On 04.12.2012 20:03, Marcos Douglas wrote: > >> > >> Hi, > >> > >> See the code below. > >> My question is: Why the cast worked, considering the c variable is a > >> TAClass instance, not a TBClass. > > > > > > As

Re: [fpc-pascal] Cast, inheritance, etc

2012-12-04 Thread Marcos Douglas
On Tue, Dec 4, 2012 at 4:53 PM, Sven Barth wrote: > On 04.12.2012 20:03, Marcos Douglas wrote: >> >> Hi, >> >> See the code below. >> My question is: Why the cast worked, considering the c variable is a >> TAClass instance, not a TBClass. > > > As long as you don't access fields of TBClass inside

Re: [fpc-pascal] Cast, inheritance, etc

2012-12-04 Thread Sven Barth
On 04.12.2012 20:03, Marcos Douglas wrote: Hi, See the code below. My question is: Why the cast worked, considering the c variable is a TAClass instance, not a TBClass. As long as you don't access fields of TBClass inside of GetInfoA you won't run into problems, because FInfoA is accessed usi