Newsgroup: it.comp.lang.c++
Titolo: How compile this file?

I have 3 files:
main.cc
esp3.h
esp3.cc
main uses the class in the esp3 files.
when I compile there are a lots of errors.
the code is right: probably I wrong in how to compile.
I do:
g++ main.cc esp3.cc -o exe_file
I write the error and the code... Just in case you want to read it!
THANK YOU In ADVANCE, Mario.
--------------------------------------------------
error-----------------------------------------------
--------------------------------------------------
[rino@localhost luigi]$ g++ main.cc esp3.cc -o exe_file
In file included from main.cc:3:
esp3.h:31: parse error before `&'
esp3.h:68: prototype for `Vett_3 Vett_3::Molt (const Mat_3_3 &)' does 
not match any in class `Vett_3'
esp3.h:31: candidate is: Vett_3 Vett_3::Molt (...)
esp3.h:109: `Fotone' was not declared in this scope
esp3.h:109: `f' was not declared in this scope
esp3.h:109: invalid data member initiailization
esp3.h:109: use `=' to initialize static data members
esp3.h:110: `Fotone' was not declared in this scope
esp3.h:110: `f' was not declared in this scope
esp3.h:110: invalid data member initiailization
esp3.h:111: `Fotone' was not declared in this scope
esp3.h:111: `f' was not declared in this scope
esp3.h:111: parse error before `&'
main.cc: In function `int main (...)':
main.cc:23: no matching function for call to `Scintillatore::Impatto 
(Fotone &)'
main.cc:29: no matching function for call to 
`Scintillatore::Interagisce (Fotone &)'
main.cc:32: warning: cannot pass objects of non-POD type `class Fotone' 
through `...'
esp3.cc:8: syntax error before `::'
esp3.cc:11: ISO C++ forbids declaration of `seed' with no type
esp3.cc:12: parse error before `}'
esp3.cc:14: syntax error before `::'
esp3.cc:17: ISO C++ forbids declaration of `seed' with no type
esp3.cc:17: redefinition of `int seed'
esp3.cc:11: `int seed' previously defined here
esp3.cc:17: `_seed' was not declared in this scope
esp3.cc:18: parse error before `}'
esp3.cc:20: syntax error before `::'
[...]
esp3.cc:139: syntax error before `::'
esp3.cc:144: syntax error before `::'
esp3.cc:149: syntax error before `::'
esp3.cc:153: syntax error before `::'
esp3.cc:157: ISO C++ forbids declaration of `m' with no type
esp3.cc:157: `m01' was not declared in this scope
esp3.cc:157: ISO C++ forbids declaration of `m' with no type
esp3.cc:157: conflicting types for `int m[0][2]'
esp3.cc:157: previous declaration as `int m[0][1]'
esp3.cc:157: `m02' was not declared in this scope
esp3.cc:158: ISO C++ forbids declaration of `m' with no type
esp3.cc:158: conflicting types for `int m[1][0]'
esp3.cc:157: previous declaration as `int m[0][2]'
esp3.cc:158: `m10' was not declared in this scope
esp3.cc:158: ISO C++ forbids declaration of `m' with no type
esp3.cc:158: conflicting types for `int m[1][1]'
esp3.cc:158: previous declaration as `int m[1][0]'
esp3.cc:158: `m11' was not declared in this scope
esp3.cc:158: ISO C++ forbids declaration of `m' with no type
esp3.cc:158: conflicting types for `int m[1][2]'
esp3.cc:158: previous declaration as `int m[1][1]'
esp3.cc:158: `m12' was not declared in this scope
esp3.cc:159: ISO C++ forbids declaration of `m' with no type
esp3.cc:159: conflicting types for `int m[2][0]'
esp3.cc:158: previous declaration as `int m[1][2]'
esp3.cc:159: `m20' was not declared in thi
[...]
esp3.cc:423: `_colonne' was not declared in this scope
esp3.cc:423: cannot convert `long unsigned int *' to `int' in 
initialization
esp3.cc:424: parse error before `for'
esp3.cc:424: `_colonne' was not declared in this scope
esp3.cc:424: parse error before `;'
esp3.cc:424: syntax error before `++'
esp3.cc:427: ISO C++ forbids declaration of `delta' with no type
esp3.cc:427: `_delta' was not declared in this scope
esp3.cc:428: ISO C++ forbids declaration of `colonne' with no type
esp3.cc:428: `_colonne' was not declared in this scope
esp3.cc:429: ISO C++ forbids declaration of `A' with no type
esp3.cc:429: `_A' was not declared in this scope
esp3.cc:430: ISO C++ forbids declaration of `min' with no type
esp3.cc:431: ISO C++ forbids declaration of `max' with no type
esp3.cc:432: parse error before `}'
esp3.cc:435: syntax error before `::'
esp3.cc:438: syntax error before `='
esp3.cc:447: `indice' was not declared in this scope
esp3.cc:447: syntax error before `++'
esp3.cc:452: syntax error before `::'
esp3.cc:454: parse error before `;'
esp3.cc:454: syntax error before `++'
-------------------------------------------------
main.c---------------------------------------------
-------------------------------------------------
#include <iostream.h>
#include <stdlib.h>
#include "esp3.h"
void main()
{
  unsigned num_fotoni = 10000, n_colonne = 400;
  Energia e_min = 0.005, delta_e = 0.005;
  double  h_legno=1., h_scint=5.08, r_scint=2.74;
  double A = 0.0697;
  Vett_3 origine(0.0, 0.0, 0.0);
  SorgenteCs sorg(origine);
  Scintillatore scint(h_legno, h_scint, r_scint);
  Istogramma isto(delta_e, n_colonne, A);
 
  unsigned i = 0;
  while(i < num_fotoni)
    {
      Fotone f = sorg.Emetti();
      Energia e_dep;
      if(scint.Impatto(f))
	{
	  e_dep = 0.0;
	  bool processa_fotone = true;
	  while(processa_fotone)
	    {
	      if(!scint.Interagisce(f)) //esce dal while
		break;
	      switch ( scint.Interazione(f, e_dep) )
		{
		case FOTOELETTRICO:
		  processa_fotone = false;
		  break;
		case COMPTON:
		  if(f.GetEnergia() < e_min)
		    processa_fotone = false;
		  break;
		default:
		  //ERRORE
		  cerr << "Errore: Tipo di interazione sconosciuto." << endl;
		  exit(0);
		}
	    }//while(processa_fotone)
	} //if(scint.Impatto(f))
      isto.Inserisci(e_dep);
 
      i++;
    }
  isto.Stampa();
}
------------------------------------------------------
esp3.cc-------------------------------------------------
------------------------------------------------------
#include <stdlib.h>   
#include <math.h> 
#include <assert.h> 
#include <iostream.h> 
 
 
//metodi di Random 
   Random::Random()
   {  
      srand(1101969);  
      seed = 1101969;  
   } 
 
   Random::Random(unsigned int _seed)  
   {  
      srand(_seed);  
      seed = _seed;  
   } 
 
   inline double Random::Uniforme() 
   { 
      double res = double(rand()) / double(RAND_MAX); 
 
      return res; 
   } 
 
//algoritmo Box-Mueller 
   inline double Random::Normale() 
   { 
      double r1 = Uniforme();  
      double r2 = Uniforme();  
      double theta = 2.0 * PI * r2; 
 
      double g = sqrt( 2.0 * log(1.0 / r1) ) * cos(theta); 
 
      return g; 
   } 
 
 
//metodi ed operatori di Vett_3 
 
   void Vett_3::Stampa()  
   { cout << "(" << v[0] << '\t' << v[1] << '\t' << v[2] << ")" << endl; } 
 
   double Vett_3::Mod()
   { 
      double ris = sqrt( v[0]*v[0] + v[1]*v[1] + v[2]*v[2] ); 
 
      return ris; 
   } 
 
   Vett_3 Vett_3::Molt(const Mat_3_3& mat) 
   { 
      Vett_3 ris; 
 
      for(int i = 0; i < 3; i++) 
      { 
         ris.v[i] = 0.0; 
         for(int j = 0; j < 3; j++) 
            ris.v[i] += mat.m[i][j] * v[i]; 
      } 
 
      return ris; 
   } 
 
   Vett_3 operator*(const double op1, const Vett_3& op2) 
   { 
      Vett_3 ris; 
 
      for(int i = 0; i < 3; i++) 
         ris.v[i] = op1 * op2.v[i]; 
 
      return ris; 
   } 
 
   Vett_3 operator+(const Vett_3& op1, const Vett_3& op2) 
   { 
      Vett_3 ris; 
 
      for(int i = 0; i < 3; i++) 
         ris.v[i] = op1.v[i] + op2.v[i]; 
 
      return ris; 
   } 
 
   double operator/(const Vett_3& op1, const Vett_3& op2) 
 
   { 
 
      double somma = 0; 
 
      for(int i = 0; i < 3; i++) 
 
      { 
 
         somma = op1.v[i] + op2.v[i] + somma; 
 
      } 
 
      return somma; 
 
   } 
 
 
//metodi di Vers_3 
 
   Vers_3::Vers_3() 
   { 
      v[0] = 1.0; 
      v[1] = 0.0; 
      v[2] = 0.0; 
   } 
 
   Vers_3::Vers_3(double x, double y, double z) : Vett_3(x, y, z) 
   { 
      double inv_rad_mod = 1.0/Mod(); 
 
      v[0] = inv_rad_mod * v[0]; 
      v[1] = inv_rad_mod * v[1]; 
      v[2] = inv_rad_mod * v[2]; 
   } 
 
   Vers_3::Vers_3(const Vett_3& v3) : Vett_3(v3)  
   { 
      double inv_rad_mod = 1.0/Mod(); 
 
      v[0] = inv_rad_mod * v[0]; 
      v[1] = inv_rad_mod * v[1]; 
      v[2] = inv_rad_mod * v[2]; 
   } 
 
   Vers_3::Vers_3(double theta, double phi) 
   { 
      v[0] = sin(theta) * cos(phi); 
      v[1] = sin(theta) * sin(phi); 
      v[2] = cos(theta); 
   } 
 
   double Vers_3::Theta() 
   { 
      return acos(v[2]); 
   } 
 
   double Vers_3::Phi() 
   { 
      return atan(v[1]/v[0]); 
   } 
 
   void Vers_3::Stampa()  
   { cout << "<" << v[0] << '\t' << v[1] << '\t' << v[2] << ">" << endl; } 
 
//metodi di Mat_3_3 
   Mat_3_3::Mat_3_3(double m00 = 0.0, double m01 = 0.0, double m02 = 0.0,
   double m10 = 0.0, double m11 = 0.0, double m12 = 0.0, 
   double m20 = 0.0, double m21 = 0.0, double m22 = 0.0)
   {
      m[0][0] = m00; m[0][1] = m01; m[0][2] = m02;
      m[1][0] = m10; m[1][1] = m11; m[1][2] = m12;
      m[2][0] = m20; m[2][1] = m21; m[2][2] = m22;
   }
   void Mat_3_3::Stampa() 
   { 
      for(int i = 0; i < 3; i++) 
      { 
         for(int j = 0; j < 3; j++) 
            cout << m[i][j] << '\t'; 
 
         cout << endl; 
      } 
   } 
 
//metodi di Cilindro 
   Cilindro::Cilindro(double h,  double a,  double r) 
   { 
      dist_sorg_scint  = h; 
      raggio  = r;
      altezza = a;
 
      theta_max =  dist_sorg_scint? atan(r/dist_sorg_scint) : PI/2.0;
   }
   bool Cilindro::Dentro(Vett_3 v)
   {
      bool res = (fabs(v.v[0]) < raggio) && (fabs(v.v[1]) < raggio) && 
         (v.v[2] < (dist_sorg_scint + altezza)) && (v.v[2] > dist_sorg_scint);
 
      return res;
   } 
 
   bool Cilindro::Incide(Vers_3 v)
   { 
      double theta_v = v.Theta();
 
      if(theta_v < theta_max)
         return true;
 
      return false;
   }
//metodi di NaI 
   float NaI::en_mu[22][3] =
   {
   0.01  ,0.6473   ,564.91466,
   0.015 ,0.59441  ,178.47173,
   0.02  ,0.58408  ,80.53353,
   0.03  ,0.56344  ,26.25452,
   0.033 ,0.55754  ,19.91214,
   0.034 ,0.55754  ,110.91797,
   0.4   ,0.54574  ,69.02874,
   0.05  ,0.52951  ,37.90681,
   0.06  ,0.51477  ,23.03908,
   0.08  ,0.48822  ,10.39856,
   0.1   ,0.46462  ,5.51639,
   0.15  ,0.41889  ,1.74074,
   0.2   ,0.38349  ,0.76699,
   0.3   ,0.33334  ,0.24485,
   0.4   ,0.29942  ,0.11372,
   0.5   ,0.27302  ,0.06401,
   0.6   ,0.25251  ,0.04086,
   0.8   ,0.22184  ,0.02109,
   1     ,0.19942  ,0.01313,
   1.5   ,0.16195  ,0.00605,
   2     ,0.1382   ,0.00369,
   3     ,0.10871  ,0.00207;
   }
 
   double NaI::MuCompton(Energia e)
   {
      register int i = 0;
 
      while( !( e >= en_mu[i][0] && e < en_mu[i+1][0]) )
         i++;
 
      double mu_compton = en_mu[i][1] + ( (en_mu[i+1][1] - en_mu[i][1]) / (en_mu[i+1][0] - en_mu[i][0]) ) * (e - en_mu[i][0]);
 
      return mu_compton;
   }
 
   double NaI::MuFotoelettrico(Energia e)
 
   {
      register int i = 0;
 
      while( !( e >= en_mu[i][0] && e < en_mu[i+1][0]) )
         i++;
 
      double mu_foto = en_mu[i][2] + ( (en_mu[i+1][2] - en_mu[i][2]) / (en_mu[i+1][0] - en_mu[i][0]) ) * (e - en_mu[i][0]);
 
      return mu_foto;
   }
   double NaI::Mu(Energia e)
 
   {
      double res = MuCompton(e) + MuFotoelettrico(e);
 
      return res;
   }
//Metodi classe Scintillatore 
   Random Scintillatore::r(6532392);
   Scintillatore::Scintillatore(double h,  double a,  double r) : Cilindro(h, a, r) {
   }
 
//se il fotone incide viene aggiornata la sua pos. con quella d'impatto
   bool Scintillatore::Impatto(Fotone& f)
   {
      if( Incide(f.propagazione) )
      {
      //Scintillatore friend di Fotone, aggiorna le coordinate di f con quelle del punto d'impatto
         f.coordinate = f.coordinate + (dist_sorg_scint/cos(f.propagazione.Theta())) * f.propagazione;
 
         return true;
      }
 
      return false;
   }
//estrae un percorso e verifica se  %/1iso8859-15 compatibile con una interazione 
   bool Scintillatore::Interagisce(Fotone& f)
   {
      Energia e_gamma = f.GetEnergia();
 
      double d = -( log(1 - r.Uniforme()) / Mu(e_gamma) );
 
   //aggiorna la posizione di possibile interazione del fotone 
      f.coordinate = f.coordinate + d * f.propagazione;
 
      if(Dentro(f.coordinate))
         return true;
 
      return false;
   }
//sceglie il tipo di interazione, se e` compton aggiorna lo stato del fotone, aggiorna l'energia depositata e quella del fotone 
   TipoInterazione Scintillatore::Interazione(Fotone& f, Energia& e_dep)
   {
      Energia e_in = f.GetEnergia();
      double prob_compton = MuCompton(e_in) / Mu(e_in);
      double p = r.Uniforme();
 
      if(p > prob_compton)
      {
      //Caso Interazione Fotoelettrica
         Interazione FOTOELETTRICO;
         Energia e_dep = e_in;
         Energia e = 0.001;
         Vett_3 coord(0,0,100);
         Vers_3 prop(0,0);
         Fotone f(e,coord,prop);
 
         return FOTOELETTRICO;
      }
      else
      {
      //Caso Interazione Compton 
         Interazione COMPTON;
         Fotone f(e,coord,prop);
         double r1 = Uniforme ();
         double r2 = Uniforme ();
         Vers_3 prop(2.0*PI*r1,PI*R2);
         double csi = prop/f.propagazione;
         Vett_3 coord = f.coordinate;
         Energia e = (mec2*e_in)/((1-csi)*e_in+mec2);
         Energia e_dep = e_in-e;
         return COMPTON;
      }
 
   }
 
 
//Metodi classe Fotone 
   Fotone::Fotone(Energia e, Vett_3 coord, Vers_3 prop)
   {
      energia = e;
      coordinate = coord;
      propagazione = prop;
   }
 
   void Fotone::Stampa()
   {
      cout << "Energia: " << energia << endl;
      coordinate.Stampa();
      propagazione.Stampa();
   }
 
//Metodi classe Sorgente e derivate 
   Random Sorgente::r;
 
   Vers_3 Sorgente::EmissioneIsotropa()
   {
      double theta = r.Uniforme() * PI;
      double phi   = r.Uniforme() * 2.0 * PI;
 
      Vers_3 res(theta, phi);
 
      return res;
   }
 
   SorgenteNa::SorgenteNa(Vett_3 ps) : Sorgente(ps) {
   }
 
   Fotone SorgenteNa::Emetti()
   {
      Energia e_source;
 
      Vers_3 propagazione = EmissioneIsotropa();
 
      if(r.Uniforme() < 0.7)
         e_source = 0.511;
      else
         e_source = 1.27;
 
      Fotone res(e_source, p, propagazione);
 
      return res;
   }
 
   SorgenteCs::SorgenteCs(Vett_3 ps) : Sorgente(ps) {
   }
 
   Fotone SorgenteCs::Emetti()
   {
      Energia e_source = 0.662;
 
      Vers_3 propagazione = EmissioneIsotropa();
 
      Fotone res(e_source, p, propagazione);
 
      return res;
   }
 
   SorgenteCo::SorgenteCo(Vett_3 ps) : Sorgente(ps) {
   }
 
   Fotone SorgenteCo::Emetti()
   { 
      Energia e_source; 
 
      Vers_3 propagazione = EmissioneIsotropa(); 
 
      if(r.Uniforme() < 0.7) 
         e_source = 1.17; 
      else 
         e_source = 1.33; 
 
      Fotone res(e_source, p, propagazione); 
 
      return res; 
 
   } 
 
//Metodi classe Istogramma 
   Random Istogramma::r(1545375); 
   Istogramma::Istogramma(Energia _delta, unsigned _colonne, double _A) 
   { 
      assert(_colonne >= 1); 
      assert(_delta > 0); 
 
      v = new unsigned long(_colonne); 
      for(unsigned i = 0; i < _colonne; i++) 
         v[i] = 0; 
 
      delta = _delta; 
      colonne = _colonne; 
      A = _A; 
      min = delta; 
      max = delta * colonne; 
   } 
 
//ritorna il valore inserito(errore gaussiano aggiunto) 
   unsigned long Istogramma::Inserisci(Energia e) 
   { 
      unsigned indice; 
      Energia e_mis = e + A * r.Normale() / sqrt(e); 
 
      if(e_mis < min) 
         indice = 0; 
      else if(e_mis > max) 
         indice = colonne-1; 
      else 
         indice = unsigned( (e_mis / max) * (colonne-1) + 1); 
 
      v[indice]++; 
 
      return indice; 
   } 
 
   void Istogramma::Stampa(ostream &os = cout) 
   {
      for(unsigned i = 0; i < colonne; i++)
         os << dec << i << "\t" << v[i] << endl;
   }
--------------------------------------------------------
esp3.h----------------------------------------------------
--------------------------------------------------------
#include <stdlib.h>   
#include <math.h> 
#include <assert.h> 
#include <iostream.h> 
 
 
//metodi di Random 
   Random::Random()
   {  
      srand(1101969);  
      seed = 1101969;  
   } 
 
   Random::Random(unsigned int _seed)  
   {  
      srand(_seed);  
      seed = _seed;  
   } 
 
   inline double Random::Uniforme() 
   { 
      double res = double(rand()) / double(RAND_MAX); 
 
      return res; 
   } 
 
//algoritmo Box-Mueller 
   inline double Random::Normale() 
   { 
      double r1 = Uniforme();  
      double r2 = Uniforme();  
      double theta = 2.0 * PI * r2; 
 
      double g = sqrt( 2.0 * log(1.0 / r1) ) * cos(theta); 
 
      return g; 
   } 
 
 
//metodi ed operatori di Vett_3 
 
   void Vett_3::Stampa()  
   { cout << "(" << v[0] << '\t' << v[1] << '\t' << v[2] << ")" << endl; } 
 
   double Vett_3::Mod()
   { 
      double ris = sqrt( v[0]*v[0] + v[1]*v[1] + v[2]*v[2] ); 
 
      return ris; 
   } 
 
   Vett_3 Vett_3::Molt(const Mat_3_3& mat) 
   { 
      Vett_3 ris; 
 
      for(int i = 0; i < 3; i++) 
      { 
         ris.v[i] = 0.0; 
         for(int j = 0; j < 3; j++) 
            ris.v[i] += mat.m[i][j] * v[i]; 
      } 
 
      return ris; 
   } 
 
   Vett_3 operator*(const double op1, const Vett_3& op2) 
   { 
      Vett_3 ris; 
 
      for(int i = 0; i < 3; i++) 
         ris.v[i] = op1 * op2.v[i]; 
 
      return ris; 
   } 
 
   Vett_3 operator+(const Vett_3& op1, const Vett_3& op2) 
   { 
      Vett_3 ris; 
 
      for(int i = 0; i < 3; i++) 
         ris.v[i] = op1.v[i] + op2.v[i]; 
 
      return ris; 
   } 
 
   double operator/(const Vett_3& op1, const Vett_3& op2) 
 
   { 
 
      double somma = 0; 
 
      for(int i = 0; i < 3; i++) 
 
      { 
 
         somma = op1.v[i] + op2.v[i] + somma; 
 
      } 
 
      return somma; 
 
   } 
 
 
//metodi di Vers_3 
 
   Vers_3::Vers_3() 
   { 
      v[0] = 1.0; 
      v[1] = 0.0; 
      v[2] = 0.0; 
   } 
 
   Vers_3::Vers_3(double x, double y, double z) : Vett_3(x, y, z) 
   { 
      double inv_rad_mod = 1.0/Mod(); 
 
      v[0] = inv_rad_mod * v[0]; 
      v[1] = inv_rad_mod * v[1]; 
      v[2] = inv_rad_mod * v[2]; 
   } 
 
   Vers_3::Vers_3(const Vett_3& v3) : Vett_3(v3)  
   { 
      double inv_rad_mod = 1.0/Mod(); 
 
      v[0] = inv_rad_mod * v[0]; 
      v[1] = inv_rad_mod * v[1]; 
      v[2] = inv_rad_mod * v[2]; 
   } 
 
   Vers_3::Vers_3(double theta, double phi) 
   { 
      v[0] = sin(theta) * cos(phi); 
      v[1] = sin(theta) * sin(phi); 
      v[2] = cos(theta); 
   } 
 
   double Vers_3::Theta() 
   { 
      return acos(v[2]); 
   } 
 
   double Vers_3::Phi() 
   { 
      return atan(v[1]/v[0]); 
   } 
 
   void Vers_3::Stampa()  
   { cout << "<" << v[0] << '\t' << v[1] << '\t' << v[2] << ">" << endl; } 
 
//metodi di Mat_3_3 
   Mat_3_3::Mat_3_3(double m00 = 0.0, double m01 = 0.0, double m02 = 0.0,
   double m10 = 0.0, double m11 = 0.0, double m12 = 0.0, 
   double m20 = 0.0, double m21 = 0.0, double m22 = 0.0)
   {
      m[0][0] = m00; m[0][1] = m01; m[0][2] = m02;
      m[1][0] = m10; m[1][1] = m11; m[1][2] = m12;
      m[2][0] = m20; m[2][1] = m21; m[2][2] = m22;
   }
   void Mat_3_3::Stampa() 
   { 
      for(int i = 0; i < 3; i++) 
      { 
         for(int j = 0; j < 3; j++) 
            cout << m[i][j] << '\t'; 
 
         cout << endl; 
      } 
   } 
 
//metodi di Cilindro 
   Cilindro::Cilindro(double h,  double a,  double r) 
   { 
      dist_sorg_scint  = h; 
      raggio  = r;
      altezza = a;
 
      theta_max =  dist_sorg_scint? atan(r/dist_sorg_scint) : PI/2.0;
   }
   bool Cilindro::Dentro(Vett_3 v)
   {
      bool res = (fabs(v.v[0]) < raggio) && (fabs(v.v[1]) < raggio) && 
         (v.v[2] < (dist_sorg_scint + altezza)) && (v.v[2] > dist_sorg_scint);
 
      return res;
   } 
 
   bool Cilindro::Incide(Vers_3 v)
   { 
      double theta_v = v.Theta();
 
      if(theta_v < theta_max)
         return true;
 
      return false;
   }
//metodi di NaI 
   float NaI::en_mu[22][3] =
   {
   0.01  ,0.6473   ,564.91466,
   0.015 ,0.59441  ,178.47173,
   0.02  ,0.58408  ,80.53353,
   0.03  ,0.56344  ,26.25452,
   0.033 ,0.55754  ,19.91214,
   0.034 ,0.55754  ,110.91797,
   0.4   ,0.54574  ,69.02874,
   0.05  ,0.52951  ,37.90681,
   0.06  ,0.51477  ,23.03908,
   0.08  ,0.48822  ,10.39856,
   0.1   ,0.46462  ,5.51639,
   0.15  ,0.41889  ,1.74074,
   0.2   ,0.38349  ,0.76699,
   0.3   ,0.33334  ,0.24485,
   0.4   ,0.29942  ,0.11372,
   0.5   ,0.27302  ,0.06401,
   0.6   ,0.25251  ,0.04086,
   0.8   ,0.22184  ,0.02109,
   1     ,0.19942  ,0.01313,
   1.5   ,0.16195  ,0.00605,
   2     ,0.1382   ,0.00369,
   3     ,0.10871  ,0.00207;
   }
 
   double NaI::MuCompton(Energia e)
   {
      register int i = 0;
 
      while( !( e >= en_mu[i][0] && e < en_mu[i+1][0]) )
         i++;
 
      double mu_compton = en_mu[i][1] + ( (en_mu[i+1][1] - en_mu[i][1]) / (en_mu[i+1][0] - en_mu[i][0]) ) * (e - en_mu[i][0]);
 
      return mu_compton;
   }
 
   double NaI::MuFotoelettrico(Energia e)
 
   {
      register int i = 0;
 
      while( !( e >= en_mu[i][0] && e < en_mu[i+1][0]) )
         i++;
 
      double mu_foto = en_mu[i][2] + ( (en_mu[i+1][2] - en_mu[i][2]) / (en_mu[i+1][0] - en_mu[i][0]) ) * (e - en_mu[i][0]);
 
      return mu_foto;
   }
   double NaI::Mu(Energia e)
 
   {
      double res = MuCompton(e) + MuFotoelettrico(e);
 
      return res;
   }
//Metodi classe Scintillatore 
   Random Scintillatore::r(6532392);
   Scintillatore::Scintillatore(double h,  double a,  double r) : Cilindro(h, a, r) {
   }
 
//se il fotone incide viene aggiornata la sua pos. con quella d'impatto
   bool Scintillatore::Impatto(Fotone& f)
   {
      if( Incide(f.propagazione) )
      {
      //Scintillatore friend di Fotone, aggiorna le coordinate di f con quelle del punto d'impatto
         f.coordinate = f.coordinate + (dist_sorg_scint/cos(f.propagazione.Theta())) * f.propagazione;
 
         return true;
      }
 
      return false;
   }
//estrae un percorso e verifica se  %/1iso8859-15 compatibile con una interazione 
   bool Scintillatore::Interagisce(Fotone& f)
   {
      Energia e_gamma = f.GetEnergia();
 
      double d = -( log(1 - r.Uniforme()) / Mu(e_gamma) );
 
   //aggiorna la posizione di possibile interazione del fotone 
      f.coordinate = f.coordinate + d * f.propagazione;
 
      if(Dentro(f.coordinate))
         return true;
 
      return false;
   }
//sceglie il tipo di interazione, se e` compton aggiorna lo stato del fotone, aggiorna l'energia depositata e quella del fotone 
   TipoInterazione Scintillatore::Interazione(Fotone& f, Energia& e_dep)
   {
      Energia e_in = f.GetEnergia();
      double prob_compton = MuCompton(e_in) / Mu(e_in);
      double p = r.Uniforme();
 
      if(p > prob_compton)
      {
      //Caso Interazione Fotoelettrica
         Interazione FOTOELETTRICO;
         Energia e_dep = e_in;
         Energia e = 0.001;
         Vett_3 coord(0,0,100);
         Vers_3 prop(0,0);
         Fotone f(e,coord,prop);
 
         return FOTOELETTRICO;
      }
      else
      {
      //Caso Interazione Compton 
         Interazione COMPTON;
         Fotone f(e,coord,prop);
         double r1 = Uniforme ();
         double r2 = Uniforme ();
         Vers_3 prop(2.0*PI*r1,PI*R2);
         double csi = prop/f.propagazione;
         Vett_3 coord = f.coordinate;
         Energia e = (mec2*e_in)/((1-csi)*e_in+mec2);
         Energia e_dep = e_in-e;
         return COMPTON;
      }
 
   }
 
 
//Metodi classe Fotone 
   Fotone::Fotone(Energia e, Vett_3 coord, Vers_3 prop)
   {
      energia = e;
      coordinate = coord;
      propagazione = prop;
   }
 
   void Fotone::Stampa()
   {
      cout << "Energia: " << energia << endl;
      coordinate.Stampa();
      propagazione.Stampa();
   }
 
//Metodi classe Sorgente e derivate 
   Random Sorgente::r;
 
   Vers_3 Sorgente::EmissioneIsotropa()
   {
      double theta = r.Uniforme() * PI;
      double phi   = r.Uniforme() * 2.0 * PI;
 
      Vers_3 res(theta, phi);
 
      return res;
   }
 
   SorgenteNa::SorgenteNa(Vett_3 ps) : Sorgente(ps) {
   }
 
   Fotone SorgenteNa::Emetti()
   {
      Energia e_source;
 
      Vers_3 propagazione = EmissioneIsotropa();
 
      if(r.Uniforme() < 0.7)
         e_source = 0.511;
      else
         e_source = 1.27;
 
      Fotone res(e_source, p, propagazione);
 
      return res;
   }
 
   SorgenteCs::SorgenteCs(Vett_3 ps) : Sorgente(ps) {
   }
 
   Fotone SorgenteCs::Emetti()
   {
      Energia e_source = 0.662;
 
      Vers_3 propagazione = EmissioneIsotropa();
 
      Fotone res(e_source, p, propagazione);
 
      return res;
   }
 
   SorgenteCo::SorgenteCo(Vett_3 ps) : Sorgente(ps) {
   }
 
   Fotone SorgenteCo::Emetti()
   { 
      Energia e_source; 
 
      Vers_3 propagazione = EmissioneIsotropa(); 
 
      if(r.Uniforme() < 0.7) 
         e_source = 1.17; 
      else 
         e_source = 1.33; 
 
      Fotone res(e_source, p, propagazione); 
 
      return res; 
 
   } 
 
//Metodi classe Istogramma 
   Random Istogramma::r(1545375); 
   Istogramma::Istogramma(Energia _delta, unsigned _colonne, double _A) 
   { 
      assert(_colonne >= 1); 
      assert(_delta > 0); 
 
      v = new unsigned long(_colonne); 
      for(unsigned i = 0; i < _colonne; i++) 
         v[i] = 0; 
 
      delta = _delta; 
      colonne = _colonne; 
      A = _A; 
      min = delta; 
      max = delta * colonne; 
   } 
 
//ritorna il valore inserito(errore gaussiano aggiunto) 
   unsigned long Istogramma::Inserisci(Energia e) 
   { 
      unsigned indice; 
      Energia e_mis = e + A * r.Normale() / sqrt(e); 
 
      if(e_mis < min) 
         indice = 0; 
      else if(e_mis > max) 
         indice = colonne-1; 
      else 
         indice = unsigned( (e_mis / max) * (colonne-1) + 1); 
 
      v[indice]++; 
 
      return indice; 
   } 
 
   void Istogramma::Stampa(ostream &os = cout) 
   {
      for(unsigned i = 0; i < colonne; i++)
         os << dec << i << "\t" << v[i] << endl;
   }


Perche' posti in inglese (maccheronico) in un NG italiano?
Tu dici "the code is right" io invece dico "the code is pretty wrong".
Se non altro per il fatto che include una serie di header che non fanno parte
dello standard da parecchio tempo (o piu' precisamente non hanno mai fatto parte
dello standard: esistevano in compilatori pre-standard). Pertanto devi
modificare il codice in modo da usare le nuove implementazioni della libreria
standard oppure compilarlo con il vecchissimo compilatore con cue era stato
creato ai suoi tempi (qualunque questo fosse).
--
Andrea Ferro
---------
Brainbench C++ Master. Scored higher than 97% of previous takers
Scores: Overall 4.46, Conceptual 5.0, Problem-Solving 5.0
More info 
http://www.brainbench.com/transcript.jsp?pid=2522556

 con cue era stato creato ai suoi tempi (qualunque questo fosse).  --
Non sò programmare in C++ benissimo... come posso risolvere praticamente
il problema?
Nel caso ciò sia troppo complesso.... ti ringrazio lo stesso!
GRAZIE, Mario.