Re: Strange bug: struct is not a type in C++?
Re: Strange bug: struct is not a type in C++?
- Subject: Re: Strange bug: struct is not a type in C++?
- From: Howard Moon <email@hidden>
- Date: Wed, 8 Oct 2008 09:13:31 -0700
#include <iostream>
template<class Type>
class class1
{
public:
struct insideStruct
{
int anyInt;
Type fData;
};
insideStruct class1Data;
};
template<class Type>
class class2
{
public:
int class2int;
struct class1<Type>::insideStruct *p1; // Compiler doesn't like this
class1<Type>::insideStruct *p2; // but is just fine with this
};
I take it you mean the other way around: the first one (with struct)
compiles, and the second doesn't, right?
This is a holdover from earlier C++ versions, before the keyword
"typename" was added to the language. Instead of adding "struct",
add "typename", and it will work (and make more sense). The keywords
"struct" and "class" are still allowed here, for backwards
compatibility, but "typename" is the correct keyword to use now.
-Howard
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden