Quantcast
Channel: CodeGuru Forums - Visual C++ Programming
Viewing all articles
Browse latest Browse all 3029

using namespace

$
0
0
Several files contain objects called Rectangle. For example it could be this version, from wingdi.h:-

Code:

WINGDIAPI BOOL    WINAPI Rectangle(HDC,int,int,int,int);
or this version which is a c'tor in a library called gdkmm:-

Code:

namespace Gdk
{

class Rectangle
{
        public:
                Rectangle();

        // whatever...
};
}

and the source code I'm building says this:-

Code:

using namespace Gdk;

Rectangle monitor;

but when I try to compile this with VS2005 it gives me this error:-

Quote:

error C2872: 'Rectangle' : ambiguous symbol
could be 'C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\wingdi.h(3514) : BOOL Rectangle(HDC,int,int,int,int)'
or 'F:\+GTK-SOURCES\gnu-windows\include\gdkmm/rectangle.h(42) : Gdk::Rectangle'
Obviously it's easy to fix - but why do I even get the error?? I've told it to use namespace Gdk - but even if I hadn't done that, the gdk version is the only one with a matching function signature. So why is the compiler even confused about this :confused:

Viewing all articles
Browse latest Browse all 3029

Latest Images

Trending Articles



Latest Images