All pastes #212457 Raw Edit

operator

public cpp v1 · immutable
#212457 ·published 2006-10-20 21:30 UTC
rendered paste body
istream& operator>>(istream& in, Money& en_money){   string s1;   string s2;   double litteral;   stringstream buffer;   pair<int,int> ett_par;      if(in.peek()!='\n')	  in >> s1;   if(in.peek()!='\n')	  in >> s2;      if(s1 != "")   {	  if(s2 == "")	  {		 /*if(en_money.valuta != s2)			throw Money::monetary_error("Currency mixing in operator"			,__LINE__);*/		 		 buffer << s1;		 buffer >> litteral;		 		 if(litteral < 0)			throw Money::monetary_error("Negative result in operator"										,__LINE__);	  }	  else if (s2 != "")	  {		 /*if(en_money.valuta != s1)			throw Money::monetary_error("Currency mixing in operator"			,__LINE__);*/		 		 buffer << s2;		 buffer >> litteral;		 		 if(litteral < 0)			throw Money::monetary_error("Negative result in operator"										,__LINE__);					 en_money.valuta = s1;	  }	  ett_par = double_to_integerpair(litteral);	  en_money.enheter = ett_par.first;	  en_money.hundradelar = ett_par.second;   }      return in;}