Sign in to follow this  
KYjanelle

sizeof static member of template class

Recommended Posts

Hi, I got a problem. I try to do something like this.
struct Foo
{
	const char *anything;
};

class Test2
{
public:
	static Foo aFoo2[];
};

Foo Test2::aFoo2[] = 
{
	{ "1" },
	{ "2" },	
};


int main()
{
	int size = sizeof( Test2::aFoo2 );
}

but on template class. I've tried code like below but it giving "illegal sizeof operand" error.
struct Foo
{
	const char *anything;
};

template<class T>
class Test
{
public:
	static Foo aFoo[];
};

template<class T>
Foo Test<T>::aFoo[] =
{
	{ "1" },
	{ "2" },
};

int main()
{
	int sizeT = sizeof( Test<int>::aFoo ); //	error
}


Thanks.

Share this post


Link to post
Share on other sites

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