You forward declare class_foo::bar
(as you can see in the eror message) but you want class_bar::bar
.
You need the forward declaration in the right namespace:
namespace class_bar {
class bar;
}
And then inside foo
you need to refer to it with the right namespace too: class_bar::bar
(rather than just bar
). And same for the other class.