Jump to content
  • Advertisement
Sign in to follow this  
samgzman

initializing member pointer to template class' member struct?

This topic is 4822 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 a template class, with a memeber struct and a static-member-pointer to this struct. I am having a nightmare of a time trying to initialize this staic pointer to null due to the templateness of the outer class. Its easy to get working when the struct is defined outside of the template class, but i don't want it to be exposed... If this is not possible, then the language seems to be incoherent since it allows templates, it allows nested classes/structs, as well as static members and pointers, but it doesnt allow a template class to init a pointer to a member struct? I would be much obliged if anyone solves this little riddle.
	template <class T>
	class A
	{
	private:

		struct B {..};

		static B* Bptr;
	};

	// I have tried the following:
	template <class T> A<T>::B*  A<T>::Bptr = 0;  // NO NO NO

	template <class T> A<T>::B* template <class T> A<T>::Bptr = 0; // Not happenin either.... :(

Share this post


Link to post
Share on other sites
Advertisement
Looks like you're missing a typename keyword. Try:

template <class T>
typename A<T>::B * A<T>::Bptr = 0;

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.

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!