Click here to Skip to main content
15,897,187 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: CHtmlView Windows 7 issue Pin
Member 810956024-Aug-11 21:21
Member 810956024-Aug-11 21:21 
GeneralRe: CHtmlView Windows 7 issue Pin
Rage24-Aug-11 21:57
professionalRage24-Aug-11 21:57 
GeneralRe: CHtmlView Windows 7 issue Pin
Member 810956024-Aug-11 23:27
Member 810956024-Aug-11 23:27 
AnswerRe: CHtmlView Windows 7 issue Pin
xrg_soft@163.com23-Aug-11 5:25
xrg_soft@163.com23-Aug-11 5:25 
GeneralRe: CHtmlView Windows 7 issue Pin
Member 810956023-Aug-11 21:31
Member 810956023-Aug-11 21:31 
GeneralRe: CHtmlView Windows 7 issue Pin
xrg_soft@163.com23-Aug-11 21:56
xrg_soft@163.com23-Aug-11 21:56 
GeneralRe: CHtmlView Windows 7 issue Pin
Member 810956023-Aug-11 22:22
Member 810956023-Aug-11 22:22 
GeneralRe: CHtmlView Windows 7 issue Pin
xrg_soft@163.com24-Aug-11 19:08
xrg_soft@163.com24-Aug-11 19:08 
GeneralRe: CHtmlView Windows 7 issue [modified] Pin
Member 810956024-Aug-11 20:22
Member 810956024-Aug-11 20:22 
GeneralRe: CHtmlView Windows 7 issue Pin
Rage24-Aug-11 4:21
professionalRage24-Aug-11 4:21 
QuestionLet a single document open Pin
_Flaviu22-Aug-11 19:38
_Flaviu22-Aug-11 19:38 
AnswerRe: Let a single document open Pin
Eugen Podsypalnikov22-Aug-11 20:50
Eugen Podsypalnikov22-Aug-11 20:50 
GeneralRe: Let a single document open Pin
_Flaviu22-Aug-11 20:55
_Flaviu22-Aug-11 20:55 
GeneralRe: Let a single document open Pin
Eugen Podsypalnikov22-Aug-11 21:06
Eugen Podsypalnikov22-Aug-11 21:06 
GeneralRe: Let a single document open Pin
_Flaviu22-Aug-11 22:44
_Flaviu22-Aug-11 22:44 
GeneralRe: Let a single document open Pin
Eugen Podsypalnikov23-Aug-11 0:41
Eugen Podsypalnikov23-Aug-11 0:41 
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 

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.