• 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: 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


References: 
 >Strange bug: struct is not a type in C++? (From: Jean-Denis Muys <email@hidden>)

  • Prev by Date: Re: Link to static library
  • Next by Date: RE: XCode and Interface builder
  • 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