#include #include #include using namespace std; class Okolina { public: double VrednostPromenljive( const string& s ) const { map::const_iterator f = _Promenljive.find(s); if( f != _Promenljive.end() ) return f->second; else{ // ovde bi trebalo da se napravi izuzetak return 0; } } bool DefinisanaPromenljiva( const string& s ) const { map::const_iterator f = _Promenljive.find(s); return f != _Promenljive.end(); } void DodajPromenljivu( const string& s, double v ) { _Promenljive[s] = v; } private: map _Promenljive; }; main() { Okolina o; o.DodajPromenljivu( "x", 2.32 ); o.DodajPromenljivu( "y", 5 ); o.DodajPromenljivu( "x", 7 ); cout << o.VrednostPromenljive( "x" ) << endl; cout << ( o.DefinisanaPromenljiva("y") ? "Imamo y." : "Nemamo y." ) << endl; cout << ( o.DefinisanaPromenljiva("z") ? "Imamo z." : "Nemamo z." ) << endl; return 0; }