Can't use namespace

Hi everyone,

I don't really understand why but although I am using a namespace the compiler tells me the class is ambiguous.

Here's the code:

1
2
3
4
5
6
7
8
9
10
11
#include "Simple_window.h" // get access to our window library
#include "Graph.h" // get access to our graphics library facilities
#include <math.h>
#include <sstream>
using namespace Graph_lib; // our graphics facilities are in Graph_lib

int main()
{
	Rectanlge rec(Point(100, 100), 50, 150);
//etc...
}


But then if I write it like this:
 
Graph_lib::Rectanlge rec(Point(100, 100), 50, 150);


it's ok.

Why is the "using" ignored?
You haven't provided "simple_window.h" or "graph.h", so anything is a guess.

Since the compiler is saying that class Rectangle (check your spelling) is ambiguous, that implies there are two classes with the name Rectangle, presumably one in "simple_window.h" and one in "graph.h".

By qualifying the class name with Graph_lib:: you have specified which one of the two to use, thereby removing the ambiguity.

BTW, the using wasn't ignored. It just brought Graph_lib into the global namespace.
Last edited on
What AbstractionAnon is saying, is that by declaring using namespace Graph_lib, "Graph_lib::Rectanlge" is now "Rectanlge" and it is conflicting with another class called "Rectanlge" somewhere in your #include chain.

Also, did you mean "Rectangle" instead of "Rectanlge"?
Topic archived. No new replies allowed.