• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Strange bug: struct is not a type in C++?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Strange bug: struct is not a type in C++?


  • Subject: Re: Strange bug: struct is not a type in C++?
  • From: Emil Pettersson <email@hidden>
  • Date: Wed, 8 Oct 2008 13:34:41 +0200

This is a feature of the C++ languange. Since it can't be determined until instantiation of the class what class1<Type>::insideStruct really is it needs to be qualified with the typename keyword (struct obviously works too). See this link for a more thurough explanation: http://pages.cs.wisc.edu/~driscoll/typename.html

Regards,

Emil

On 8 okt 2008, at 13.14, Jean-Denis Muys wrote:


On 8 oct. 08, at 10:38, Nicholaz Beresford wrote:

	class1::insideStruct *p1;
	class1::insideStruct *p2;


Unsurprisingly, this doesn't work as you cannot use a template class without specifying the actual type parameter.

Indeed, the compiler complains on this with :

/.../main.cpp:24: error: 'template<class Type> class class1' used without template parameters
/.../main.cpp:24: error: ISO C++ forbids declaration of 'insideStruct' with no type
/.../main.cpp:24: error: expected ';' before '*' token


(also, in my original code, the comments were reversed: the line without "struct" is rejected, while the line with "struct" compiles fine).

Jean-Denis

_______________________________________________
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


_______________________________________________ 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
References: 
 >Strange bug: struct is not a type in C++? (From: Jean-Denis Muys <email@hidden>)
 >Re: Strange bug: struct is not a type in C++? (From: Nicholaz Beresford <email@hidden>)
 >Re: Strange bug: struct is not a type in C++? (From: Jean-Denis Muys <email@hidden>)

  • Prev by Date: Re: Strange bug: struct is not a type in C++?
  • Next by Date: Re: Link to static library
  • Previous by thread: Re: Strange bug: struct is not a type in C++?
  • Next by thread: Re: Strange bug: struct is not a type in C++?
  • Index(es):
    • Date
    • Thread