|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
DetectorMessenger .hh里面报错 ‘B1’ has not been declared class B1::DetectorConstruction;
我尝试在DetectorMessenger 的.hh文件里面也使用命名空间,报了另一个错
- //
- //
- #ifndef B1_DETECTORMESSENGER_HH
- #define B1_DETECTORMESSENGER_HH
- #include "G4UImessenger.hh"
- #include "globals.hh"
- #include "G4UImessenger.hh"
- #include "globals.hh"
- class B1::DetectorConstruction;
- class G4UIdirectory;
- class G4UIcmdWithAString;
- class G4UIcmdWithAnInteger;
- class G4UIcmdWithADoubleAndUnit;
- class G4UIcmdWithoutParameter;
- //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
- class DetectorMessenger : public G4UImessenger {
- public:
- DetectorMessenger(B1::DetectorConstruction *);
- ~DetectorMessenger();
- virtual void SetNewValue(G4UIcommand *, G4String);
- private:
- G4UIcmdWithADoubleAndUnit *fDetThickCmd;
- B1::DetectorConstruction *fDetectorConstruction;
- G4UIdirectory *fTestemDir;
- G4UIdirectory *fDetDir;
- };
- //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
- #endif //B1_DETECTORMESSENGER_HH
复制代码
另一个类 DetectorConstruction里面使用了命名空间
//
/// \file DetectorConstruction.hh
/// \brief Definition of the B1::DetectorConstruction class
#ifndef B1DetectorConstruction_h
#define B1DetectorConstruction_h 1
#include "G4VUserDetectorConstruction.hh"
#include "globals.hh"
class G4VPhysicalVolume;
class G4LogicalVolume;
class G4Material;
class G4MaterialCutsCouple;
class G4UniformMagField;
class DetectorMessenger;
/// Detector construction class to define materials and geometry.
namespace B1
{
class RunAction;
class DetectorConstruction : public G4VUserDetectorConstruction
{
public:
// DetectorConstruction(RunAction* runAction);
DetectorConstruction();
~DetectorConstruction() override;
G4VPhysicalVolume* Construct() override;
// for change Det Params
void SetDetThickness(G4double);
G4double GetDetThickness() const {return fDetThickness;};
protected:
G4LogicalVolume* fScoringVolume = nullptr;
G4LogicalVolume *fLogicTubeTarget= nullptr;
G4LogicalVolume *fLogicCryst= nullptr;
private:
RunAction* fRunAction = nullptr;
G4double fDetThickness;
void ChangeGeometry();
DetectorMessenger* fDetectorMessenger;
};
}
#endif
复制代码
然后在DetectorConstruction.cc的构造函数里初始化的时候,fDetectorMessenger = new DetectorMessenger(this);报错了
#include "G4LogicalVolumeStore.hh"
#include "DetectorMessenger.hh"
#include "DetectorConstruction.hh"
#include "DetectorMessenger.hh"
namespace B1
{
DetectorConstruction::DetectorConstruction()
:G4VUserDetectorConstruction(),
fLogicTubeTarget(nullptr),
fLogicCryst(nullptr),
fDetectorMessenger(nullptr)
{
// create commands for interactive definition
fDetectorMessenger = new DetectorMessenger(this);
}
}
复制代码 |
|