C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Vererbung und Instanzierung

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ (German)
View previous topic :: View next topic  
Author Message
Thoschi
Guest





PostPosted: Wed Mar 02, 2005 4:10 pm    Post subject: Vererbung und Instanzierung Reply with quote



Hallo,

ich möchte, dass eine CallBack-Funktion von einer abgeleiteten Klasse
eine Funktion aufruft. Für jede Applikation verwende ich eine andere
abgeleitete Klasse mit der selben (abstrakten) Basisklasse und selben
CallBackFkt.
Was muss ich tun, damit diese CallBackFkt, welche die abgeleiteten
Klassen nicht kennt, trotzdem die abgeleitete Funktion aufruft.

Beispiel
-------------------------
int CallBackFkt()
{
MyA.Hugo();
}

Class A
{
int Hugo();
}
-------------------------

Class AB::A
{
int virtual Hugo();
}

AB MyA;
-------------------------

Class AC::A
{
int virtual Hugo();
}

AC MyA;
-------------------------

Ich hoffe ich habe mein Problem halbwegs verständlich machen können.

Vielen Dank,
Thomas

--
de.comp.lang.iso-c++ - Moderation: mailto:voyager+mod (AT) bud (DOT) prima.de
FAQ: http://www.voyager.prima.de/cpp/ mailto:voyager+send-faq (AT) bud (DOT) prima.de
Back to top
Thomas Maeder
Guest





PostPosted: Wed Mar 02, 2005 8:47 pm    Post subject: Re: Vererbung und Instanzierung Reply with quote



[email]tschindler2000 (AT) hotmail (DOT) com[/email] (Thoschi) writes:

Quote:
ich möchte, dass eine CallBack-Funktion von einer abgeleiteten Klasse
eine Funktion aufruft. Für jede Applikation verwende ich eine andere
abgeleitete Klasse mit der selben (abstrakten) Basisklasse und selben
CallBackFkt.
Was muss ich tun, damit diese CallBackFkt, welche die abgeleiteten
Klassen nicht kennt, trotzdem die abgeleitete Funktion aufruft.

Beispiel
-------------------------

A &makeA();


Quote:
int CallBackFkt()
{
MyA.Hugo();

makeA().Hugo();

Quote:
}

Class A
{
int Hugo();

virtual int Hugo() = 0;

Quote:
}
-------------------------

Class AB::A
{
int virtual Hugo();

virtual int Hugo();

Quote:
}

AB MyA;
-------------------------

Class AC::A
{
int virtual Hugo();

virtual int Hugo();

Quote:
}

AC MyA;
-------------------------

Zudem ersetzt die die globalen MyA durch eine geeignete Funktion
makeA(), welche Du in jeder Applikation anders implementierst.

--
de.comp.lang.iso-c++ - Moderation: mailto:voyager+mod (AT) bud (DOT) prima.de
FAQ: http://www.voyager.prima.de/cpp/ mailto:voyager+send-faq (AT) bud (DOT) prima.de

Back to top
Thoschi
Guest





PostPosted: Thu Mar 03, 2005 8:44 am    Post subject: Re: Vererbung und Instanzierung Reply with quote



Hallo Thomas,

danke, der Kompilier hat's gefressen und ich habe es auch kapiert.

Und vielen Dank, dass du mir nicht die Formfehler um die Ohren gehauen
hast. Im Moment als ich den Beitrag abgeschickt habe (No preview) habe
ich meinen Fehler gesehen.

Quote:
Class AB::A
Class AB : public A
{
}

Viele Grüße,
Thomas

--
de.comp.lang.iso-c++ - Moderation: mailto:voyager+mod (AT) bud (DOT) prima.de
FAQ: http://www.voyager.prima.de/cpp/ mailto:voyager+send-faq (AT) bud (DOT) prima.de

Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ (German) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.