Jump to content
  • Advertisement

Archived

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

pschmitt

Template Class frustration

This topic is 5392 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!