error: conversion from ‘<unresolved overloaded function type>’ to non-scalar type
error: conversion from ‘<unresolved overloaded function type>’ to non-scalar type
LSR 配置 class 定义为:
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
我正在使用上述 class 的实例,如下所示。
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);
并出现以下编译错误。有人可以解释为什么会出现此错误吗?
../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
这只是一个拼写错误:您应该调用方法 CreateObject
,但您试图将类型 LsrConfig
的对象作为模板参数传递而不是它:
// Ptr<lsr::LsrConfig> lsrConfig = CreateObject<lsr::LsrConfig()>;
// note the parenthesis ^^ vv
Ptr<lsr::LsrConfig> lsrConfig = CreateObject<lsr::LsrConfig >();
这是另一个可能导致此错误的示例:
struct A
{
};
std::shared_ptr<A> a = std::make_shared<A>;
error: conversion from ‘<unresolved overloaded function type>’ to non-scalar type ‘std::shared_ptr<main()::A>’ requested
解决方法是再次添加括号:
std::shared_ptr<A> a = std::make_shared<A>();
LSR 配置 class 定义为:
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
我正在使用上述 class 的实例,如下所示。
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);
并出现以下编译错误。有人可以解释为什么会出现此错误吗?
../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
这只是一个拼写错误:您应该调用方法 CreateObject
,但您试图将类型 LsrConfig
的对象作为模板参数传递而不是它:
// Ptr<lsr::LsrConfig> lsrConfig = CreateObject<lsr::LsrConfig()>;
// note the parenthesis ^^ vv
Ptr<lsr::LsrConfig> lsrConfig = CreateObject<lsr::LsrConfig >();
这是另一个可能导致此错误的示例:
struct A
{
};
std::shared_ptr<A> a = std::make_shared<A>;
error: conversion from ‘<unresolved overloaded function type>’ to non-scalar type ‘std::shared_ptr<main()::A>’ requested
解决方法是再次添加括号:
std::shared_ptr<A> a = std::make_shared<A>();