// Code derived from Stroustrup's PPP2 book// § 6.3.3 Implementing tokens// -and beginning on p 183#include<iostream>#include<stdexcept>usingstd::cerr;usingstd::cout;usingstd::exception;usingstd::runtime_error;voiderror(constchar*s){throwruntime_error(s);}// a very simple user-defined typeclassToken{public:charkind='0';doublevalue=0.0;};intmain()try{Tokent;// t is a Tokent.kind='+';// t represents a +Tokent2;// t2 is another Tokent2.kind='8';// we use the digit 8 as the "kind" for numberst2.value=3.14;Tokentt=t;// copy initializationif(tt.kind!=t.kind)error("impossible!");t=t2;// assignmentcout<<t.value<<'\n';// will print 3.14}catch(exception&e){cerr<<"error: "<<e.what()<<'\n';return1;}catch(...){cerr<<"Oops: unknown exception!\n";return2;}