Access of variable from another Class

Dear Lammps Users,

I am trying to reproduce the calculation of pair force in my Fix class.
I include the pair.h, and trying to access some variable like the *list defined in pair.h
by pair->list.
But the compiler gives the error that pair is not declared.

How to access the member in another class, like using *list in fix_xx.cpp.

Thanks!

Dear Lammps Users,

I am trying to reproduce the calculation of pair force in my Fix class.
I include the pair.h, and trying to access some variable like the **list*
defined in pair.h
by *pair->list*.
But the compiler gives the error that pair is not declared.

​and rightfully so. pair is not a member of Fix.

if you need a neighbor list in your fix, you can create a request for it.​
​see for example how it is done in fix bond/create.​

How to access the member in another class, like using *list in fix_xx.cpp.

​for selected members you can use the extract() method.​

​axel.​

Dear Axel,

Thanks so much for your suggestion!

Also, I found that the list can be accessed by using force->pair->list,
it seems that member of force, as well as member of the member, can be accessible directly.

Is it correct to do this?

Thanks!