Click here to Skip to main content
15,913,685 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: CallBack in C++ class Pin
ThatsAlok7-Jul-06 0:33
ThatsAlok7-Jul-06 0:33 
GeneralRe: CallBack in C++ class Pin
Daniel Kanev7-Jul-06 1:07
Daniel Kanev7-Jul-06 1:07 
AnswerRe: CallBack in C++ class Pin
Justin Tay6-Jul-06 23:14
Justin Tay6-Jul-06 23:14 
GeneralRe: CallBack in C++ class Pin
Daniel Kanev7-Jul-06 1:06
Daniel Kanev7-Jul-06 1:06 
AnswerRe: CallBack in C++ class Pin
David Crow7-Jul-06 3:23
David Crow7-Jul-06 3:23 
QuestionClass communication Pin
HakunaMatada6-Jul-06 22:41
HakunaMatada6-Jul-06 22:41 
AnswerRe: Class communication Pin
ThatsAlok6-Jul-06 22:57
ThatsAlok6-Jul-06 22:57 
AnswerRe: Class communication Pin
Steve Echols6-Jul-06 23:05
Steve Echols6-Jul-06 23:05 
Yes it's possible, but you'll have to seperate declaration from implementation:

In .h:
<br />
class A;<br />
class B;<br />
<br />
class A<br />
{<br />
public:<br />
    B* m_pB;<br />
<br />
    void callB();<br />
    void doSomething();<br />
};<br />
<br />
class B<br />
{<br />
public:<br />
    A* m_pA;<br />
<br />
    void callA();<br />
    void doSomething();<br />
};<br />


In .cpp:
void A::callB()<br />
{<br />
    m_pB->doSomthing();<br />
}<br />
<br />
void A::doSomething()<br />
{<br />
    // do whatever to A<br />
}<br />
<br />
void B::callA()<br />
{<br />
    m_pA->doSomthing();<br />
}<br />
<br />
void B::doSomething()<br />
{<br />
    // do whatever to B<br />
}<br />


Usage:
A a;<br />
B b;<br />
<br />
a.m_pB = &b;<br />
b.m_pA = &a;<br />
<br />
a.callB();<br />
b.callA();<br />


Pretty generic, hope that helps.


- S
50 cups of coffee and you know it's on!
AnswerRe: Class communication Pin
David Crow7-Jul-06 3:27
David Crow7-Jul-06 3:27 
QuestionFinding duplicates Pin
RChin6-Jul-06 22:34
RChin6-Jul-06 22:34 
AnswerRe: Finding duplicates Pin
Steve Echols6-Jul-06 22:53
Steve Echols6-Jul-06 22:53 
GeneralRe: Finding duplicates Pin
RChin7-Jul-06 9:02
RChin7-Jul-06 9:02 
Questionstill about modeless dialog Pin
Desmo166-Jul-06 22:25
Desmo166-Jul-06 22:25 
AnswerRe: still about modeless dialog Pin
Sarath C6-Jul-06 22:34
Sarath C6-Jul-06 22:34 
AnswerRe: still about modeless dialog Pin
Hamid_RT6-Jul-06 23:08
Hamid_RT6-Jul-06 23:08 
GeneralRe: still about modeless dialog Pin
Desmo166-Jul-06 23:40
Desmo166-Jul-06 23:40 
GeneralRe: still about modeless dialog Pin
Hamid_RT6-Jul-06 23:52
Hamid_RT6-Jul-06 23:52 
GeneralRe: still about modeless dialog Pin
ashish dogra7-Jul-06 0:17
ashish dogra7-Jul-06 0:17 
GeneralRe: still about modeless dialog Pin
Desmo167-Jul-06 0:30
Desmo167-Jul-06 0:30 
GeneralRe: still about modeless dialog Pin
Desmo167-Jul-06 0:30
Desmo167-Jul-06 0:30 
GeneralRe: still about modeless dialog Pin
Hamid_RT7-Jul-06 0:48
Hamid_RT7-Jul-06 0:48 
GeneralRe: still about modeless dialog Pin
huynhnb7-Jul-06 2:04
huynhnb7-Jul-06 2:04 
GeneralRe: still about modeless dialog Pin
Hamid_RT7-Jul-06 0:47
Hamid_RT7-Jul-06 0:47 
AnswerRe: still about modeless dialog Pin
David Crow7-Jul-06 3:38
David Crow7-Jul-06 3:38 
GeneralRe: still about modeless dialog Pin
Desmo169-Jul-06 21:25
Desmo169-Jul-06 21:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.