Click here to Skip to main content
15,904,351 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: tab control and property pages problem Pin
FISH78622-Apr-09 9:24
FISH78622-Apr-09 9:24 
QuestionRe: tab control and property pages problem Pin
David Crow22-Apr-09 9:27
David Crow22-Apr-09 9:27 
AnswerRe: tab control and property pages problem Pin
FISH78622-Apr-09 9:28
FISH78622-Apr-09 9:28 
GeneralRe: tab control and property pages problem Pin
David Crow22-Apr-09 9:41
David Crow22-Apr-09 9:41 
GeneralRe: tab control and property pages problem Pin
FISH78622-Apr-09 9:59
FISH78622-Apr-09 9:59 
QuestionCDO mail header setting please help Pin
only_jack22-Apr-09 2:25
only_jack22-Apr-09 2:25 
QuestionRetrieve data field from HL7 message in VC++ Pin
Abhijit D. Babar22-Apr-09 1:55
Abhijit D. Babar22-Apr-09 1:55 
QuestionRe: Retrieve data field from HL7 message in VC++ Pin
David Crow22-Apr-09 4:58
David Crow22-Apr-09 4:58 
AnswerRe: Retrieve data field from HL7 message in VC++ Pin
Stuart Dootson22-Apr-09 5:28
professionalStuart Dootson22-Apr-09 5:28 
GeneralRe: Retrieve data field from HL7 message in VC++ Pin
David Crow22-Apr-09 5:37
David Crow22-Apr-09 5:37 
GeneralRe: Retrieve data field from HL7 message in VC++ Pin
Abhijit D. Babar24-Apr-09 0:17
Abhijit D. Babar24-Apr-09 0:17 
AnswerRe: Retrieve data field from HL7 message in VC++ Pin
Abhijit D. Babar24-Apr-09 0:21
Abhijit D. Babar24-Apr-09 0:21 
QuestionEmail Notification for Outlook Express 6 Pin
ganesh.dp22-Apr-09 1:28
ganesh.dp22-Apr-09 1:28 
AnswerRe: Email Notification for Outlook Express 6 Pin
Divyang Mithaiwala22-Apr-09 1:33
Divyang Mithaiwala22-Apr-09 1:33 
GeneralRe: Email Notification for Outlook Express 6 Pin
ganesh.dp22-Apr-09 1:52
ganesh.dp22-Apr-09 1:52 
QuestionRe: Email Notification for Outlook Express 6 Pin
David Crow22-Apr-09 5:28
David Crow22-Apr-09 5:28 
AnswerRe: Email Notification for Outlook Express 6 Pin
Divyang Mithaiwala22-Apr-09 18:46
Divyang Mithaiwala22-Apr-09 18:46 
QuestionRe: Email Notification for Outlook Express 6 Pin
David Crow22-Apr-09 5:31
David Crow22-Apr-09 5:31 
AnswerRe: Email Notification for Outlook Express 6 Pin
Stuart Dootson22-Apr-09 5:44
professionalStuart Dootson22-Apr-09 5:44 
QuestionFunction Pointers in Classes Pin
Arsalan Malik22-Apr-09 0:01
Arsalan Malik22-Apr-09 0:01 
AnswerRe: Function Pointers in Classes Pin
Stephen Hewitt22-Apr-09 0:25
Stephen Hewitt22-Apr-09 0:25 
GeneralRe: Function Pointers in Classes Pin
Arsalan Malik23-Apr-09 23:21
Arsalan Malik23-Apr-09 23:21 
QuestionRe: Function Pointers in Classes Pin
ParagPatel22-Apr-09 0:25
ParagPatel22-Apr-09 0:25 
AnswerRe: Function Pointers in Classes Pin
Divyang Mithaiwala22-Apr-09 0:33
Divyang Mithaiwala22-Apr-09 0:33 
AnswerRe: Function Pointers in Classes Pin
Stuart Dootson22-Apr-09 3:32
professionalStuart Dootson22-Apr-09 3:32 
I would implement this using Boost.Function[^] and Boost.Bind[^]:

In class B, declare display like this:

boost::function<void(char*)> display;


in A, set b.display like this:

B b;
b.display = boost::bind(&A::display, this);


in B, call it like this:

if (display) display(whatever string you want to display


The if (display) bit is to protect you against the case that nothing's been assigned to B::display.

Here's a complete, buildable and runnable example:

#include <iostream>
#include <boost/bind.hpp>
#include <boost/function.hpp>

class B
{
public:
   boost::function<void(char*)> display;
   void b_test() { if (display) display("test"); }
};

class A
{
public:
   A() { b.display = boost::bind(&A::display, this, _1); }
   void a_test() { b.b_test(); }
   void display(char* s) { std::cout << s << std::endl; }
   B b;
};

int main()
{
   A a;
   a.a_test();
}


Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

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.