To forward a type in a namespace: namespace ns1 { class a; } Your are using `a` a member of ``consumer` which means it needs concrete type, your forward declaration won't work for this case.