Search code examples
c++arraysns-3

Error while creating array of objects in NS-3 (C++)


In an NS-3 .cc file I am trying to create an array of instantiations of the UdpEchoClientHelperclass, just by doing:

UdpEchoClientHelper echoClient[NO_OF_NODES];

and when I am trying to build I am getting the error message:

../scratch/test.cc:55:33: error: no matching function for call to ‘ns3::UdpEchoClientHelper::UdpEchoClientHelper()’

Am I doing something wrong at the array declaration?


Solution

  • There's no matching constructor for

    UdpEchoClientHelper::UdpEchoClientHelper()
    

    These are the available constructors:

       /**
       * Create UdpEchoClientHelper which will make life easier for people trying
       * to set up simulations with echos.
       *
       * \param ip The IP address of the remote udp echo server
       * \param port The port number of the remote udp echo server
       */
      UdpEchoClientHelper (Address ip, uint16_t port);
      /**
       * Create UdpEchoClientHelper which will make life easier for people trying
       * to set up simulations with echos.
       *
       * \param ip The IPv4 address of the remote udp echo server
       * \param port The port number of the remote udp echo server
       */
      UdpEchoClientHelper (Ipv4Address ip, uint16_t port);
      /**
       * Create UdpEchoClientHelper which will make life easier for people trying
       * to set up simulations with echos.
       *
       * \param ip The IPv6 address of the remote udp echo server
       * \param port The port number of the remote udp echo server
       */
      UdpEchoClientHelper (Ipv6Address ip, uint16_t port);
    

    You should take a look to the tutorials first.