Issue regarding Scoring Volume and energy deposition

src/stepping.cc: In member function ‘virtual void MySteppingAction::UserSteppingAction(const G4Step*)’:
src/stepping.cc:18:10: error: ‘fScoringVolume’ was not declared in this scope
18 | if (!fScoringVolume) return;
| ^~~~~~~~~~~~~~

This is what is shown in the terminal after the run the code. I have defined fScoringVolume within MyDetectorConstruction class and included MyDetectorConstruction.hh in stepping.hh and still this error keeps showing.
Please help.

Dear @Rudradeb30 ,

You claim you defined fScoringVolume within MyDetectorConstruction but you intend to use it in the class MySteppingAction. Those are separate classes.

If you are unfamiliar with C++ I suggest you take some online tutorial. Geant4 application typicaly use rather simple C++ but it is still C++.

Good luck.

/Pico

Thank you the problem is solved now, i defined fScoringVolume within stepping.hh also and it works.