-
May 4th, 2015, 01:18 PM
#1
error: expected constructor, destructor, or type conversion before ‘(’
Hi. I'm new to c++ programming and currently I'm trying to write a code in Geant4 toolkit. Basically, I have this class that gives one error when compiling.
RunAction.cc:
Code:
#include "RunAction.hh"
#include "Run.hh"
#include "GeometriaConstruction.hh"
#include "PrimaryGeneratorAction.hh"
#include "HistoManager.hh"
#include "G4Run.hh"
#include "G4RunManager.hh"
#include "G4UnitsTable.hh"
#include "G4SystemOfUnits.hh"
#include "Randomize.hh"
#include <iomanip>
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
RunAction::RunAction (DetectorConstruction* det, PrimaryGeneratorAction* prim)
: G4UserRunAction(),
fDetector(det), fPrimary(prim), fRun(0), fHistoManager(0)
{
// Book predefined histograms
fHistoManager = new HistoManager();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
RunAction::~RunAction()
{
delete fHistoManager;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4Run* RunAction::GenerateRun()
{
fRun = new Run(fDetector);
return fRun;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void RunAction::BeginOfRunAction(const G4Run*)
{
// save Rndm status
G4RunManager::GetRunManager()->SetRandomNumberStore(false);
if (isMaster) G4Random::showEngineStatus();
// keep run condition
if (fPrimary) {
G4ParticleDefinition* particle
= fPrimary->GetParticleGun()->GetParticleDefinition();
G4double energy = fPrimary->GetParticleGun()->GetParticleEnergy();
fRun->SetPrimary(particle, energy);
}
//histograms
//
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
if ( analysisManager->IsActive() ) {
analysisManager->OpenFile();
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void RunAction::EndOfRunAction(const G4Run*)
{
if (isMaster) fRun->EndOfRun();
//save histograms
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
if ( analysisManager->IsActive() ) {
analysisManager->Write();
analysisManager->CloseFile();
}
// show Rndm status
if (isMaster) G4Random::showEngineStatus();
}
RunAction.hh:
Code:
#ifndef RunAction_h
#define RunAction_h 1
#include "G4UserRunAction.hh"
#include "globals.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
class GeometriaConstruction;
class Run;
class PrimaryGeneratorAction;
class HistoManager;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
class RunAction : public G4UserRunAction
{
public:
RunAction(GeometriaConstruction*, PrimaryGeneratorAction*);
~RunAction();
public:
virtual G4Run* GenerateRun();
virtual void BeginOfRunAction(const G4Run*);
virtual void EndOfRunAction(const G4Run*);
private:
GeometriaConstruction* fDetector;
PrimaryGeneratorAction* fPrimary;
Run* fRun;
HistoManager* fHistoManager;
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#endif
The following error when trying to compile is:
Code:
geo@george-Ubuntu:~/Desktop/teste$ make
Scanning dependencies of target ribras
[ 6%] Building CXX object CMakeFiles/ribras.dir/src/RunAction.cc.o
/home/geo/Desktop/from the scratch/src/RunAction.cc:18:22: error: expected constructor, destructor, or type conversion before ‘(’ token
RunAction::RunAction (DetectorConstruction* det, PrimaryGeneratorAction* prim)
^
make[2]: *** [CMakeFiles/ribras.dir/src/RunAction.cc.o] Error 1
make[1]: *** [CMakeFiles/ribras.dir/all] Error 2
make: *** [all] Error 2
Anyone got an Idea of how Can I fix it? I've tried searching on stackexchange and ther sites but couldn't come up with a solution.
If needed I can try uploading other files I've written.
Thanks
-
May 4th, 2015, 02:08 PM
#2
Re: error: expected constructor, destructor, or type conversion before ‘(’
This has been answered elsewhere. Next time, I suggest that you post on a single help channel at a time, and if and when you move to a different help channel, inform.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|