Click here to Skip to main content
16,015,756 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Let a single document open Pin
_Flaviu23-Aug-11 1:51
_Flaviu23-Aug-11 1:51 
GeneralRe: Let a single document open Pin
Eugen Podsypalnikov23-Aug-11 5:39
Eugen Podsypalnikov23-Aug-11 5:39 
GeneralRe: Let a single document open Pin
_Flaviu22-Aug-11 22:46
_Flaviu22-Aug-11 22:46 
AnswerRe: Let a single document open Pin
Richard MacCutchan22-Aug-11 22:45
mveRichard MacCutchan22-Aug-11 22:45 
GeneralRe: Let a single document open Pin
_Flaviu22-Aug-11 22:49
_Flaviu22-Aug-11 22:49 
QuestionPointer to member function in struct Pin
Dean Seo22-Aug-11 18:29
Dean Seo22-Aug-11 18:29 
AnswerRe: Pointer to member function in struct Pin
Eugen Podsypalnikov22-Aug-11 20:59
Eugen Podsypalnikov22-Aug-11 20:59 
GeneralRe: Pointer to member function in struct Pin
Dean Seo22-Aug-11 21:16
Dean Seo22-Aug-11 21:16 
Thanks.


Eugen Podsypalnikov wrote:
typedef void (*LPSTATEPROC) (void);


You meant this, right?
typedef void (CAccount::*LPSTATEPROC) (void);


But it seems like it doesn't still work and the error occurs at the same line.

#include 
#include 

#define KEY_ESC     27

using std::cout;
using std::endl;

class CAccount;

typedef void (CAccount::*LPSTATEPROC) (void);

struct StateMap
{
	int input;
	LPSTATEPROC mfp;
};
class CAccount
{
public:
	enum
	{
		STATE_IDLE,
		STATE_INPUT,
		STATE_WAIT_ACK
	};

public:
	StateMap	map[3];
	int			m_iState;

	CAccount();

	void OnIdle();
	void OnInput();
	void OnWaitAck();
};//class CAccount


CAccount::CAccount(){
	map[0].input = 1;
	map[0].mfp = &CAccount::OnIdle;

	map[1].input = 2;
	map[1].mfp = &CAccount::OnInput;

	map[2].input = 3;
	map[2].mfp = &CAccount::OnWaitAck;

	m_iState = STATE_IDLE;
}

void CAccount::OnIdle()
{
	cout << "OnIdle()" << endl;
}

void CAccount::OnInput()
{
	cout << "OnInput()" << endl;
}

void CAccount::OnWaitAck()
{
	cout << "OnWaitAck()" << endl;
}


int main()
{
	int         ch = 0;
	int         i;
	CAccount    account;

	while ( ch != KEY_ESC )
	{
		ch = _getch();
		i  = 0;
		while ( account.map[i].input != 0 )
		{
			if ( ch == account.map[i].input )
			{
				(account.(map[i].*mfp))(); // compile error
			}//if
			i++;
		}//while
	}//while

	return 0;
}//main()


How can I change that error line to make it work?

Thanks!
GeneralRe: Pointer to member function in struct Pin
Richard MacCutchan22-Aug-11 22:43
mveRichard MacCutchan22-Aug-11 22:43 
GeneralRe: Pointer to member function in struct Pin
Chang Su Lee24-Aug-11 5:29
Chang Su Lee24-Aug-11 5:29 
GeneralRe: Pointer to member function in struct Pin
Richard MacCutchan24-Aug-11 6:09
mveRichard MacCutchan24-Aug-11 6:09 
GeneralRe: Pointer to member function in struct Pin
Dean Seo22-Aug-11 21:27
Dean Seo22-Aug-11 21:27 
QuestionIDE from programm in C++ Pin
Chargoy22-Aug-11 16:04
Chargoy22-Aug-11 16:04 
AnswerRe: IDE from programm in C++ Pin
Richard Andrew x6422-Aug-11 16:13
professionalRichard Andrew x6422-Aug-11 16:13 
AnswerRe: IDE from programm in C++ PinPopular
Albert Holguin22-Aug-11 16:40
professionalAlbert Holguin22-Aug-11 16:40 
GeneralRe: IDE from programm in C++ Pin
Chargoy27-Aug-11 5:43
Chargoy27-Aug-11 5:43 
QuestionHandle bluetooth pairing code Pin
Vijay Rajanna22-Aug-11 7:15
Vijay Rajanna22-Aug-11 7:15 
AnswerRe: Handle bluetooth pairing code Pin
«_Superman_»22-Aug-11 8:47
professional«_Superman_»22-Aug-11 8:47 
QuestionVC6 C++ can I prevent an "Internet Explorer Script Error" debug dialog popup [modified] Pin
cgb14322-Aug-11 6:43
cgb14322-Aug-11 6:43 
AnswerRe: VC6 C++ can I prevent an "Internet Explorer Script Error" debug dialog popup Pin
Code-o-mat22-Aug-11 7:46
Code-o-mat22-Aug-11 7:46 
GeneralRe: VC6 C++ can I prevent an "Internet Explorer Script Error" debug dialog popup Pin
cgb14322-Aug-11 9:12
cgb14322-Aug-11 9:12 
GeneralRe: VC6 C++ can I prevent an "Internet Explorer Script Error" debug dialog popup Pin
Code-o-mat22-Aug-11 9:40
Code-o-mat22-Aug-11 9:40 
GeneralRe: VC6 C++ can I prevent an "Internet Explorer Script Error" debug dialog popup Pin
xrg_soft@163.com23-Aug-11 5:37
xrg_soft@163.com23-Aug-11 5:37 
GeneralRe: VC6 C++ can I prevent an "Internet Explorer Script Error" debug dialog popup Pin
cgb14323-Aug-11 6:28
cgb14323-Aug-11 6:28 
GeneralRe: VC6 C++ can I prevent an "Internet Explorer Script Error" debug dialog popup Pin
xrg_soft@163.com23-Aug-11 21:47
xrg_soft@163.com23-Aug-11 21:47 

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.