Typename confusion

I know how to use typename, but apparently it's not supposed to be used in this sense:

1
2
3
4
5
6
template < typename SignedOrUnsigned > class ForFileIO {
	public:

		virtual typename SignedOrUnsigned char*	CharArray ( );
		virtual	void				LoadFromCharArray ( char* Array );
};


Obviously, I'm trying to allow the user to use the template to determine whether or not the return type of the method (Sorry if I got my terms mixed up) CharArray should be signed or unsigned. During compilation, the compiler is saying that char* shouldn't be after SignedOrUnsigned.

I'd rather not go through and have to make 2 different functions to perform only slightly different tasks. While I suppose it's alright to just use a signed char array and have the user cast each index, I thought it would be nicer to be a bit neater with this and have the user do a bit less.. Either way, I'd still like to know if something like this is possible.
Last edited on
You can't use it like that. unsigned by itself is already a type, and even if it wasn't, that's not how templates work. The user would need to pass <unsigned char> or <char>.
In any case, there's no difference. Return either one and the user can cast to the other type if he needs to:
uchar *v=(uchar *)/*...*/CharArray();
Alright, thanks.
Topic archived. No new replies allowed.