Jump to content
  • Advertisement


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

Roof Top Pew Wee

Operator Overloading and templates - ok, but not together.

This topic is 5560 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'm just learning these two subjects, and I think I understand them separately, but when I put them together I have problems. So let's say I have a template and I want to overload an operator like so:

template <class cType> class dArray
	cType arrayVariable[1024];
	dArray operator[](int numToReturn);

// then outside of the class:

template <class cType> cType dArray<cType>::operator[](int numToReturn)
	return arrayVariable[numToReturn];

It's throwing an error when I write this. Could someone help me out. I haven't found any tutorials that do this. Only tutorials that do one or the other, and I've had to try to put it together on my own, unsuccessfully. --Vic-- The future of 2D game development: Flat Red Ball

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!