错误:从'<unresolved overloaded function type>'转换为非标量类型

Ani*_*ilJ 2 c++ stl

LSR配置类定义为:

 29 namespace ns3 {
 30 namespace lsr {
 31 
 32 #include <map>
 33 #include <vector>
 34 
 35 class LsrConfig : public Object
 36 {
 37 
 38 public:
 39 
 40   LsrConfig ();
 41   ~LsrConfig ();
 42 
208 };
209
210 }} // namespace lsr,ns3
Run Code Online (Sandbox Code Playgroud)

我正在使用上面的类的实例如下.

172   //@@Set configuration.
174   Ptr<lsr::LsrConfig> lsrConfig = CreateObject<lsr::LsrConfig()>;
175   lsrConfig->SetNetworkAttributes (network, site, routerName, logLevel);
176   lsrConfig->SetHelloProtocolAttributes (helloRetries, helloTimeout, helloInterval, adjLsaBuildInterval, firstHelloInterval);
Run Code Online (Sandbox Code Playgroud)

并获得以下编译错误.有人可以解释为什么会出现这个错误?

../src/lsr-topology-reader.cc: In member function ‘ns3::Ptr<ns3::Node> ns3::LsrTopologyReader::CreateNode(std::string, double, double, std::string, std::string, std::string, std::string, double, double, double, double, double, double, double, std::string, double, double, std::string, double, double, uint32_t)’:
../src/lsr-topology-reader.cc:174:38: error: conversion from ‘<unresolved overloaded function type>’ to non-scalar type ‘ns3::Ptr<ns3::lsr::LsrConfig>’ requested
Run Code Online (Sandbox Code Playgroud)

awe*_*oon 5

这只是一个错字:您应该调用该方法CreateObject,但是您尝试将类型的对象LsrConfig作为模板参数传递而不是它:

// Ptr<lsr::LsrConfig> lsrConfig = CreateObject<lsr::LsrConfig()>;
//                                      note the parenthesis  ^^ vv
   Ptr<lsr::LsrConfig> lsrConfig = CreateObject<lsr::LsrConfig  >();
Run Code Online (Sandbox Code Playgroud)