using keyword problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxxxx   or  artursz@xxxxxxxxxxx

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux