This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
using keyword problem
- From: Artur Szostak <artur at alice dot phy dot uct dot ac dot za>
- To: gcc-help at gcc dot gnu dot org
- Date: Fri, 27 Aug 2004 13:52:03 +0200
- Subject: using keyword problem
- Reply-to: artur at alice dot phy dot uct dot ac dot za
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