[ndnSIM] [EXT] Private Class Error even after an Attempt to Fix

Junxiao Shi shijunxiao at email.arizona.edu
Thu Jul 1 06:37:45 PDT 2021

Hi Justin

You are supposed to call SetPosition
function from outside.
The DoSetPosition virtual function is for subclasses to implement the
functionality, and should not be used elsewhere.
See Public Virtual Methods: A Bad Idea
for why ns-3 designed it this way.

Yours, Junxiao

On Mon, Jun 28, 2021 at 12:39 PM Justin Rodrigues via ndnSIM <
ndnsim at lists.cs.ucla.edu> wrote:

> *External Email*
> Hello Everyone,
> I hope you are doing well.
> Currently I am facing an error like this which I am unsure how to correct
> since I have not had it before in c++.
> ../src/ndnSIM/examples/mobility-tree-walk3.cpp: In function ‘int
> ns3::main(int, char**)’:
> ../src/ndnSIM/examples/mobility-tree-walk3.cpp:171:37: error: ‘virtual
> void ns3::ConstantVelocityMobilityModel::DoSetPosition(const Vector&)’ is
> private within this context
>    myM.DoSetPosition(Vector(10,10,10));
>                                      ^
> In file included from ./ns3/mobility-module.h:14:0,
>                  from ../src/ndnSIM/examples/mobility-tree-walk3.cpp:24:
> ./ns3/constant-velocity-mobility-model.h:59:16: note: declared private here
>    virtual void DoSetPosition (const Vector &position);
>                 ^~~~~~~~~~~~~
> Waf: Leaving directory
> `/home/justin/Downloads/ndn_sim_mobility/ndnsim/ns-3/build'
> Build failed
>  -> task in 'mobility-tree-walk3' failed with exit status 1 (run with -v
> to display more information)
> It is not letting me access a function since its declared as private so I
> havedeclared the function in the c++ document and edited that file to make
> the function pubilc yet ns-3 still thinks its private.
> Sincerely,
> Justin Rodrigues
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.lists.cs.ucla.edu/pipermail/ndnsim/attachments/20210701/483b7774/attachment.html>

More information about the ndnSIM mailing list