I was doing a Monte-Carlo simulation, and try to read a file full of deals' information at a timestamp. In my struct Timestamp, the _time and _spot_rate are both set to be private, and initialized as following:
unsigned int _time = 0;
float _spot_rate = 1.0;
However, when I am calling the following function, and use Timestamp as a parameter, it keeps reconstructing every time in the getline() loop. Thus I am wondering why is this happened and has this anything to do with the getline function?
void MCSimulation::readDeals(const Timestamp node){
std::string line;
unsigned int cp_marker = 0; //let this markdown which counterparty we are currently reviewing
double net_exposure = 0; //this is to memorize each counterparty's net_exposure, and updated while passing each deal
int test = 0;
//nothing wrong here for node time and spot rate.
//std::cout << "node time: " << node.getTime() << std::endl;
//std::cout << "node spot rate: " << node.getSpotRate() << std::endl;
while(std::getline(_deal_file, line)){
test += 1;
//*********************************************something wrong here that set node time being zero
std::cout << "node time: " << node.getTime() << std::endl;
....
Aucun commentaire:
Enregistrer un commentaire