Re: Event handlers...



A class is defined by an entry in the "type" clause in your code.
Something which starts with ...

TSomeObject = class(TSomeOtherObject) ...

Any the headers of any methods are declared in this declaration by
"procedure DoThis(" or "function GetThat(". Later on in the unit the
code in the method is declared. For that method code to be associated
by the compiler with the type declaration, it must have the type quoted
in the method code header. So code for the methods has the class name
as a prefix in that header eg ...

procedure TSomeObject.DoThis(...

.... and it is this classname prefix which is missing from your code and
so upsetting the compiler.

Methods are called differently from general procedures & functions. An
extra parameter named Self is passed to a method. This parameter is a
reference (OK - a pointer for people talking dirty) to the instance of
the class which called the method. For the DoSomething method called by
an instance of TSomeObject named MyObject it would be a reference to
MyObject. This allows any method to know which particular object is
calling it.

All _methods_ have _one_ chunk of code for _all_ instances of the
object. _Separate_ chunks of memory hold _data_ (property and
variables) for _each_ instance of the object. So method code _must_
know which instance is calling it.

Alan Lloyd

.



Relevant Pages

  • Re: regarding external function(Ss)
    ... than having a "#include" for the header file that declares it. ... extern void *malloc; ... effectively copies the contents of that header into your source file. ... declaration is from an included header or from the source file itself. ...
    (comp.lang.c)
  • Re: Quantized Indexing Source Code (update & alg. history)
    ... This however is not (unless the header is used in only one place). ... the same variable in multiple translation units ... if you have conflicting definitions it just arbitrarily and without ...
    (comp.compression)
  • Re: enum variables and extern
    ... Now when I try to reference enum_var in data.h, ... You need to define 'enum myenum' everywhere you reference it. ... single declaration can be convenient, ... The problem here is that it's in a header, ...
    (comp.lang.c)
  • Re: innerHTML = responseText generates invalid chars
    ... a character set declaration in properly served markup, ... served with a proper Content-Type header, ... You are confusing the Document Character Set and the document encoding, ... describes the range of characters that can be displayed with an HTML document. ...
    (comp.lang.javascript)
  • Re: [PATCH v3] ftrace: add a tracepoint for __raise_softirq_irqoff()
    ... On Mon, 11 May 2009, Mathieu Desnoyers wrote: ... Circular header dependencies is a real problem ... It is because struct irqaction's ... TP_PROTO just needs a forward declaration, ...
    (Linux-Kernel)