Hi everyone.

Hi everyone.

While maintaning some old code I came across some weird use of an object.

It is something like this: pastebin.com/MbA7mnnc

I don't understand how is this possible. I was expecting an Access Violation exception or some kind of error. After all the object was not initialized.

Any clarifications will be welcome.

Comments

  1. Alexander Sviridenkov I always tought that for a method to be static I must have to use the class keyword, otherwise it will fail when called like that.

    Attila Kovacs It is indeed the same question. Unfortunatelly I missed that post.

    ReplyDelete
  2. You're just returning a constant value. Try Result := ToString :)

    ReplyDelete
  3. Gustavo Ribeiro Croscato there are 'normal' methods which has hidded instance parameter, class methods (declared with 'class') with hidden class parameter and class static methods with no hidden parameters (declared with 'class' and 'static').
    Non-virtual normal methods can be called without creating object instance, if no object fields are used inside method.

    ReplyDelete

Post a Comment