// Code derived from Stroustrup's PPP2 book// § 6.8.1 Implementing Token_stream// -and beginning on p 211#include<iostream>#include<stdexcept>#include<string>usingnamespacestd;voiderror(constchar*s){throwruntime_error(s);}//------------------------------------------------------------------------------classToken{public:Token(charch):kind{ch}{}Token(charch,doubleval):kind{ch},value{val}{}charkind='0';doublevalue=0.0;};//------------------------------------------------------------------------------classToken_stream{public:Token_stream();// make a Token_stream that reads from cinTokenget();// get a Tokenvoidputback(Tokent);// put a Token backprivate:boolfull;// is there a Token in the buffer?Tokenbuffer;// here is where we keep a Token put back using putback()};//------------------------------------------------------------------------------Token_stream::Token_stream():full{false},buffer{0}// no Token in buffer{}//------------------------------------------------------------------------------voidToken_stream::putback(Tokent){if(full)error("putback() into a full buffer");buffer=t;// copy t to bufferfull=true;// buffer is now full}//------------------------------------------------------------------------------intmain()try{Token_streamts;ts.putback(')');}catch(exception&e){cerr<<e.what()<<'\n';return1;}catch(...){cerr<<"exception \n";return2;}