error: expected primary expression before const in ns3

113 views
Skip to first unread message

Mohammad Umar Sattar

unread,
Oct 15, 2016, 7:56:14 AM10/15/16
to ns-3-users, rao.s...@gmail.com
Here is my Code:

  NodeContainer nodes;
  nodes.Create (2); //creat 2 nodes they are p2p

  PointToPointHelper pointToPoint;
  pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("2Mbps"));
  pointToPoint.SetChannelAttribute ("Delay", StringValue ("20ms"));

  NetDeviceContainer devices;// put nodes in ndc
  devices = pointToPoint.Install (nodes);
////give them an address
  InternetStackHelper stack;
  stack.Install (nodes);
    Ipv4AddressHelper address;
    address.SetBase ("109.11.12.0", "255.255.255.0");//address setting

    Ipv4InterfaceContainer interfaces = address.Assign (devices);
////Node Container 1 End Here...

/////Node Contatiner 2
  NodeContainer nodes1;
 
  nodes1.Add(nodes.Get(1));
  nodes1.Create (2); //creat 2 nodes they are p2p
 

  PointToPointHelper pointToPoint1;
  pointToPoint1.SetDeviceAttribute ("DataRate", StringValue ("2Mbps"));
  pointToPoint1.SetChannelAttribute ("Delay", StringValue ("20ms"));

  NetDeviceContainer devices1;// put nodes in ndc
  devices1 = pointToPoint1.Install (nodes1);
////give them an address
  InternetStackHelper stack1;
  stack1.Install (nodes1);
    Ipv4AddressHelper address1;
    address1.SetBase ("107.11.12.0", "255.255.255.0");//address setting

    Ipv4InterfaceContainer interfaces1 = address.Assign (devices1);
////Node Container 2 End Here..


/////Node Contatiner 3
  NodeContainer nodes2;
 
 nodes2.Add(const NodeContainer &nodes,const NodeContainer &nodes1);

Showing Me This Error... Searched alot but No Solution Found....

../scratch/Test.cc: In function ‘int main(int, char**)’:
../scratch/Test.cc:214:13: error: expected primary-expression before ‘const’
  nodes2.Add(const NodeContainer &nodes,const NodeContainer &nodes1); //creat 2 nodes they are p2p
             ^
../scratch/Test.cc:214:40: error: expected primary-expression before ‘const’
  nodes2.Add(const NodeContainer &nodes,const NodeContainer &nodes1); //creat 2 nodes they are p2p

Help me where are am doing wrong.... Thanks in advance

pdbarnes

unread,
Oct 15, 2016, 11:33:49 AM10/15/16
to ns-3-users
You pasted in the declaration for Add(). You probably mean

nodes2.Add (nodes1);

Peter

Mohammad Umar Sattar

unread,
Oct 16, 2016, 8:33:57 AM10/16/16
to ns-3-users
Thanks Done with it
Reply all
Reply to author
Forward
0 new messages