C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old May 4th, 2015, 02:14 PM
gabuds gabuds is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2015
Posts: 1 gabuds User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 19 sec
Reputation Power: 0
Syntax errors - 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........oooOO0OO  ooo........oooOO0OOooo......

RunAction::RunAction (DetectorConstruction* det, PrimaryGeneratorAction* prim)
  : G4UserRunAction(),
    fDetector(det), fPrimary(prim), fRun(0), fHistoManager(0)
{
 // Book predefined histograms
 fHistoManager = new HistoManager();
}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OO  ooo........oooOO0OOooo......

RunAction::~RunAction()
{
 delete fHistoManager;
}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OO  ooo........oooOO0OOooo......

G4Run* RunAction::GenerateRun()
{
  fRun = new Run(fDetector);
  return fRun;
}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OO  ooo........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........oooOO0OO  ooo........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........oooOO0OO  ooo........oooOO0OOooo......

class GeometriaConstruction;
class Run;
class PrimaryGeneratorAction;
class HistoManager;

//....oooOO0OOooo........oooOO0OOooo........oooOO0OO  ooo........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........oooOO0OO  ooo........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

Reply With Quote
  #2  
Old May 14th, 2015, 02:52 AM
Thinias Thinias is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2010
Posts: 78 Thinias User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 h 58 m 48 sec
Reputation Power: 8
The method signature in your class definition (RunAction.hh) and in your implementation (RunAction.cc) do not match.

from .hh:
RunAction(GeometriaConstruction*, PrimaryGeneratorAction*);

from .cc:
RunAction::RunAction (DetectorConstruction* det, PrimaryGeneratorAction* prim)


Because they don't match, the definition in your .cc is not recognized as a valid constructor.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > Syntax errors - Error: expected constructor, destructor, or type conversion before (


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.

© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap