Topic: each function


Author: fall@disuns2.epfl.ch (Saloum Fall)
Date: 13 Sep 91 14:22:39 GMT
Raw View
Hi there,

Here is my problem : I'm programming in C++ while using MacApp 2.0.1 classes.
In the file UList.h there is a class (TList) which provide the following
method:

virtual pascal void
Each(pascal void (*DoToItem)(TObject *item, void *DoToItem_StaticLink),
     void *DoToItem_StaticLink);

I have two object for test:

1) TMyObject whose only job is to return the name of the object:
pascal void TMyObject::TheName() {return this->fName;}

2) TTest is an object who has a field "TList* fMyList", and who provides
the following method:
pascal void TTest::EachDo(pascal void DoThis(TObject *anObject))
{fMyList->Each(DoThis);}

Finally i have a function Affiche() who belongs to no object:
pascal void Affiche(TObject *anObject) {
TMyObject *aMyObject = (TMyObjet *)anObject;
DrawString(aMyObject->TheName());
}

What i want to do is to apply this last function to each element (same type as
TMyObject) of the list which is pointed by the fMyList field of a TTest object.

If i do it like preceeding the compilator give me this message:
#error: bad argument 1 type for TList::Each() pascal void (*)(TObject **)
( pascal void (*)(TObject **, void *) expected)
This error is located on the line {fMyList->Each(DoThis);}

As i'm not a specialist of programming in C++ i can't solve this problem.
If you can help ..
Is it possible to use this instruction : aTest->EachDo(Affiche)

Thanx for any help, and forgive for all my mistakes.

--
Please email
*******************************************
*email :  fall@disuns2.epfl.ch      *
*******************************************
*Lausanne Federal Institute of Technology *
*******************************************