I have following code, which has circular dependency as well as each class use a different name space. I am getting the following compilation error. I am not sure what is the correct solution to resolve this error. Tried few things, but unsuccessful. Can someone point the correct code?
Apart from circular dependency, I am more unclear of implications of different namespaces, if any, and how if it affects the dependency in some way.
I have pasted excerpts from the original program files.
// ndn-nlsr-app.hpp
19 #include "model/nlsr/name-prefix-table.hpp"
21
22 namespace ns3 {
23 namespace ndn {
24
25 class NlsrApp: public App {
26
27 public:
65 nlsr::NamePrefixTable&
66 getNamePrefixTable()
67 {
68 return m_namePrefixTable;
69 }
70
103 nlsr::NamePrefixTable m_namePrefixTable;
108 };
109
110 }//namespace ndn
111 }//namespace ns3
// name-prefix-table.hpp
9 #include "apps/ndn-nlsr-app.hpp"
10 namespace ns3 {
11 namespace nlsr {
12
13 class NamePrefixTable
14 {
15 public:
16 NamePrefixTable(ndn::NlsrApp& nlsr)
17 : m_nlsr(nlsr)
18 {
19 }
40 private:
41 ndn::NlsrApp& m_nlsr;
42 };
44
45 }//namespace nlsr
46 }//namespace ns3
In file included from ../src/ndnSIM/apps/ndn-nlsr-app.hpp:19:0,
from ../src/ndnSIM/apps/ndn-nlsr-app.cpp:1:
../src/ndnSIM/model/nlsr/name-prefix-table.hpp:17:31: error: expected ‘)’ before ‘&’ token
../src/ndnSIM/model/nlsr/name-prefix-table.hpp:42:3: error: ‘NlsrApp’ in namespace ‘ns3::ndn’ does not name a type
In file included from ../src/ndnSIM/model/nlsr/name-prefix-table.hpp:9:0,
from ../src/ndnSIM/model/nlsr/name-prefix-table.cpp:5:
../src/ndnSIM/apps/ndn-nlsr-app.hpp:65:3: error: ‘NamePrefixTable’ in namespace ‘ns3::nlsr’ does not name a type
../src/ndnSIM/apps/ndn-nlsr-app.hpp:103:3: error: ‘NamePrefixTable’ in namespace ‘ns3::nlsr’ does not name a type