Class and Instance having same name

I

ibm

Consider the following code snippet:

....
class XXXX
{
public:
XXXX()
{
cout << " XXXX Constructor " << endl;
};

int i;
};


class YYYY
{
public:
YYYY()
{
cout << " YYYY Constructor " << endl;
};

int i;
class XXXX XXXX; // compiles ( g++ )
// XXXX XXXX; // does not compile
};
....

Note the declaration/definition of an instance XXXX of class XXXX in
class YYYY.
It is my contention ( and g++ seems to agree ) that such a construct
ought to be in error.
VIsual C++ and another as yet unknown compiler ( the problem occurs in
some third party code ) seem to have no trouble with the commented out
code ( XXXX XXXX; ).
What I'm looking for is material to wrap around a blunt object which I
may then
use to correct the offending third party if the fact the situation is
as I suspect.
Thanx.

IBM
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top