Trying to compile the code below fails due to a "conflicting declaration". Why can't I define a forward declared class like this?
I did this to hide that the implementation uses a certain library. Although I'll admit that this does not really abstract anything - you'll still need to know what the implementation uses to make the correct call - I am still interested in why this doesn't work.
Bar.cpp:
#include "Bar.hpp"
#include "Foo.hpp"
using Foo = ns::Foo;
void Bar::foo(Foo f) {
}
Bar.hpp:
class Foo;
class Bar {
void foo(Foo f);
};
Foo.hpp:
namespace ns {
class Foo {
};
}
To be clear, I want to know why can't define a previously declared class by aliasing - in other words saying "use that definition over there that has a different name"