sizeof static member of template class

Started by
1 comment, last by KYjanelle 17 years, 1 month ago
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.
Advertisement
Compiles fine here (gcc 4.1.2). Your compiler might be broken :|
Well I hope not. lol
Fyi, I'm using MS VS.2005.
any other suggestion? thanks.

This topic is closed to new replies.

Advertisement