This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++ porting to GCC problem


Hi,

I'm porting some C++ originally written in Visual Studio to GCC. I've hit one snag that I can't explain and I'd like to get some help please!

The following bit of code is a simplified version of the full code, but it replicates the essential form of the problem exactly.

When using g++ (v3.3.3 on Cygwin or v3.2 on Redhat) with no extra command line options, it produces a parse error at the indicated line. However when compiled under Borland 6 or SGI MIPs (with their ANSI switches turned on) it compiles with no whinges and produces the right output (the number 2) when run.

Is this an illegal bit of syntax permitted by other compilers (I promise that there is a good reason for this structure in the original program!), or is it a g++ thing?

Thanks in advance


#include <iostream> using namespace std; /*------------------------------------*/ class A { public: enum Fish { Carp, Haddock, Cod }; };

/*------------------------------------*/
template<class T>
class Z
{
public:
	Z(){}

	int MakeFish()
	{
		T::Fish theFish = T::Cod; <-------------Parse error here before ";"

		cout << theFish << endl;
		return 0;
	}
};

/*------------------------------------*/
int main()
{
	Z<A> hello;

hello.MakeFish();

	return 0;
}



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]