Advertisement Jump to content
Sign in to follow this  
ZedFx

One For C++ Template Gurus

This topic is 4993 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

A quick one for you template gurus, cast your eyes over the following...

template <typename T> class Test
{	
	private:
	
	// private members here
	
	public:
	
	Test(void);
	~Test(void);
	Test(const Test<T> & a);
	Test<T> & operator =(const Test<T> & a);
	
	T & Func1(const T & Item);
	T & Func2(const Test<T> & a);
	
};

template <typename T> Test<T>::Test(void)
{

}

template <typename T> Test<T>::~Test(void)
{

}

template <typename T> Test<T>::Test(const Test<T> & a)
{

}

template <typename T> Test<T> & Test<T>::operator =(const Test<T> & a)
{

}

template <typename T> T & Test<T>::Func1(const T & Item)
{

}

template <typename T> T & Test<T>::Func2(const Test<T> & a)
{

}



Can you spot any syntax errors, general errors, compiler errors, or any sort of implicit or explicit error! If there are any problems can you advise me of the best programming practice.

Share this post


Link to post
Share on other sites
Advertisement
Quote:

Can you spot any syntax errors


build - 0 error(s), 0 warning(s)

that's what compilers are for.

Quote:

general errors, compiler errors, or any sort of implicit or explicit error!

If there are any problems can you advise me of the best programming practice.

Be carefull to put the implementation in the header file. I prefer to put the implementation inside the class declaration, but that is a matter of taste.

Oh, and the naming of the parameters is inconsistent, "a" and "Item", choose a style and stick with it.

Share this post


Link to post
Share on other sites
Haha! thankyou for pointing out the blatantly obvious, it was just an example after all.

A simple yes would have sufficed to say its fine, but thanks for your responses.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!