trial and error, emphases on error

Trying to convert from std::string to char*

Using const_cast Operator

We know that both string::c_str or string::data functions returns const char*. To get a non-const version, we can use the const_cast operator, which removes the const attribute from a class. This works in constant time as no copying is involved.

Please note that this approach will give us direct access…

--

--

Example:

MobilityHelper mobility;
Ptr<ListPositionAllocator> positionAlloc = CreateObject <ListPositionAllocator>();
positionAlloc ->Add(Vector(0, 0, 0)); // node0
positionAlloc ->Add(Vector(1000, 0, 0)); // node1
positionAlloc ->Add(Vector(450, 0, 0)); // node2
mobility.SetPositionAllocator(positionAlloc);
mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
mobility.Install(nodes);

References

[1] Google Groups. ns3. Assign Positions to Mesh Nodes. https://groups.google.com/g/ns-3-users/c/8e7fIZTMV_A?pli=1

--

--