Archived

This topic is now archived and is closed to further replies.

pschmitt

Template Class frustration

Recommended Posts

I have the following defined in a class, TextBox
	void SetChangeEvent(void (*ChangeHandler)(char *)) { changeHandler = ChangeHandler; }
	void SetAcceptEvent(void (*AcceptHandler)(char *)) { acceptHandler = AcceptHandler; }

	template 
	void SetChangeEvent(T *ChangeListener, void (T::*ChangeHandler)(char *))
	{ changeListener = (EventListener *)ChangeListener; dChangeHandler = (void (EventListener::*)(char *))ChangeHandler; }

	template 
	void SetAcceptEvent(T *AcceptListener, void (T::*AcceptHandler)(char *))
	{ acceptListener = (EventListener *)AcceptListener; dAcceptHandler = (void (EventListener::*)(char *))AcceptHandler; }
  
And I want to call the template class version of the above via the following call: TextBox w0TextBox; w0TextBox.SetChangeEvent(this, &Application::w0Update); w0TextBox.SetAcceptEvent(this, &Application::w0Update); where Application::w0Update() updates values in my Text Box. BUT I get the following error: Compiling... Application.cpp C:\path.to\Application.cpp(249) : error C2660: 'SetChangeEvent' : function does not take 2 parameters C:\path.to\Application.cpp(250) : error C2660: 'SetAcceptEvent' : function does not take 2 parameters Error executing cl.exe. Any idea of what I'm doing wrong? Thanks, Pete [edited by - pschmitt on November 15, 2003 5:48:20 PM]

Share this post


Link to post
Share on other sites
Figured it out.

For inquiring minds:
void SetChangeEvent(T *ChangeListener, void (T::*ChangeHandler)(char *))

T::*ChagneHandler(char *)
the change handler function needs to take a char*

SO... w0Update() must take a char. . .

Fixed it & it''s working fine now.

Sorry for the useless post

-Pete

Share this post


Link to post
Share on other sites