To be able to better understand what typecasting is, you need to know what
strong typing means. Not fully correct, but you can think typecasting as a command to convert the data to another type, for example from Integer to Real.
Read here if you want to learn more:
https://wiki.freepascal.org/TypecastTo be able to better understand what reference counting means, you need to know how the data being stored. Have you ever manually allocate some memory to a
pointer and do some processing on it? If you have not, then it will be a bit difficult to explain reference counting to you. Reference counting is a technique to manage when the data in the memory can to be freed. If the counting = 0, it means the data can be freed because no one using it.
Read here if you want to learn more:
https://en.wikipedia.org/wiki/Reference_countingFor your information, AnsiString is reference counted but ShortString is not. You only will know why, if you understand how they store their data.