mardi 23 mai 2017

How to passe a argv parameter to a constructor of another class?[c++]

Well, I am a new to the c++ and I meet some problem. I have a mainfunction receiving some argv parameters from a shell script and my another class wanna use on of the parameters,I have tried many answer but all didn't work, so I put my code here and hope somebody can help me out.

#include head.hh
  int main(int argc, char *argv[])
{

  int DataSize  = atoi(argv[1]);
  ...
}
  ...


#include head.hh


 Benchmark::Benchmark(...)

{
    FederateName = Name;
    DataSizeByte = DataSize;
    ...
}
    ...


I haved simplfied the codes and my goal is the parameter DataSize(argv[1]) can be passed to _DataSize which is in constructor of class Benchmark.

Aucun commentaire:

Enregistrer un commentaire