Sign in to follow this  

initializing member pointer to template class' member struct?

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

This topic is 4485 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this