Reputation: 2121
A LSR configuration class is defined as:
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
I am using an instance of above class as follows.
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);
and getting the following compilation error. Can someone please explain why this error coming?
../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
Upvotes: 3
Views: 6780
Reputation: 602
Here is another example which can cause this error:
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
And the solution is again to add parenthesis:
std::shared_ptr<A> a = std::make_shared<A>();
Upvotes: 2
Reputation: 33691
It is just a typo: you should call the method CreateObject
, but instead of it you are trying to pass object of type LsrConfig
as template parameter:
// Ptr<lsr::LsrConfig> lsrConfig = CreateObject<lsr::LsrConfig()>;
// note the parenthesis ^^ vv
Ptr<lsr::LsrConfig> lsrConfig = CreateObject<lsr::LsrConfig >();
Upvotes: 5