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]

using keyword problem


Why does the following code not compile under GCC?
Is this not valid C++?

class A
{
public:
	struct S
	{
		int x;
	};
};

int Method()
{
	using A::S;

	S s;
	s.x = 1;
	return s.x;
};


When compiling the above code as is from source file main.cxx the following 
output is generated:

$ g++ main.cxx -o test
main.cxx: In function `int Method()':
main.cxx:12: parse error before `::' token
main.cxx:14: `S' undeclared (first use this function)
main.cxx:14: (Each undeclared identifier is reported only once for each
   function it appears in.)
main.cxx:15: `s' undeclared (first use this function)
$


-- 

Artur Szostak

Physics Department
University of Cape Town
Rondebosch
7701
South Africa

Work: +27 21 650 3356
Mobile: +27 82 297 9502
Email: artur@alice.phy.uct.ac.za   or  artursz@iafrica.com


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