马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 猪猪虾 于 2023-7-24 22:54 编辑
//
/// \file ActionInitialization.hh
/// \brief Definition of the B3b::ActionInitialization class
#ifndef B3bActionInitialization_h
#define B3bActionInitialization_h 1
#include "G4VUserActionInitialization.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
namespace B3
{
class DetectorConstruction;
}
namespace B3b
{
/// Action initialization class.
class ActionInitialization : public G4VUserActionInitialization
{
public:
ActionInitialization(B3::DetectorConstruction* detConstruction);
~ActionInitialization() override;
void BuildForMaster() const override;
void Build() const override;
private:
B3::DetectorConstruction* fdetectorConstruction = nullptr;
};
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#endif
//
/// \file ActionInitialization.cc
/// \brief Implementation of the B3b::ActionInitialization class
#include "ActionInitialization.hh"
#include "RunAction.hh"
#include "PrimaryGeneratorAction.hh"
#include "StackingAction.hh"
#include "PrimaryGeneratorAction.hh"
#include "DetectorConstruction.hh"
#include "Run.hh"
using namespace B3;
namespace B3b
{
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ActionInitialization::ActionInitialization(DetectorConstruction* detConstruction)
:fdetectorConstruction(detConstruction)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ActionInitialization::~ActionInitialization()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void ActionInitialization::BuildForMaster() const
{
SetUserAction(new RunAction);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void ActionInitialization::Build() const
{
SetUserAction(new RunAction);
SetUserAction(new PrimaryGeneratorAction(fdetectorConstruction));
SetUserAction(new StackingAction);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
}
#endif
从你提供的错误信息来看,问题出在 ActionInitialization 类的构造函数声明和定义不匹配。
根据错误信息,构造函数的原型(声明)是 ActionInitialization::ActionInitialization(B3b::DetectorConstruction*),但在类的定义中,构造函数是 ActionInitialization::ActionInitialization(DetectorConstruction* detConstruction)。
错误的原因可能是类 B3b::DetectorConstruction 的前缀被遗漏或者参数名称不匹配。为了解决这个问题,你需要做以下步骤:
1. 确保在构造函数的声明和定义中使用相同的类名作为参数类型。检查 DetectorConstruction 类的前缀是否为 B3b::。
2. 检查参数名称是否一致,包括大小写。确保在构造函数的声明和定义中使用相同的参数名称。
下面是一个示例,展示如何修正构造函数声明和定义的不匹配问题:
// 在声明中添加正确的前缀 'B3b::'
ActionInitialization::ActionInitialization(B3b::DetectorConstruction* detConstruction);
// 在定义中使用相同的参数类型和名称
ActionInitialization::ActionInitialization(B3b::DetectorConstruction* detConstruction) {
// 构造函数的实现代码
}
请根据实际情况检查和修改构造函数的声明和定义,确保它们匹配并且编译通过。
希望这个回答对你有所帮助。如果你还有其他问题,请随时提问。
如果问题已经解决,请设置最佳答案
|