1 #ifndef H_ValType 2 #define H_ValType 3 4 #include <iostream> 5 #include <string> 6 7 using namespace std; 8 9 class ValType { 10 public: 11 ValType(const string & s) 12 : str(s) 13 { used = false; } 14 15 ~ValType() 16 { 17 if (!used) 18 cerr << "error: ambiguous return type" << endl; 19 } 20 21 // conversion operators 22 operator double(); 23 operator double*(); 24 operator vector<double>(); 25 operator vector<int>(); 26 operator int(); 27 operator string(); 28 29 private: 30 bool used; 31 string str; 32 33 int get_int(string str); 34 double get_double(string str); 35 double *get_double_array(string str); 36 vector<double> get_vector(string str); 37 vector<int> get_ivector(string str); 38 string get_string(string str); 39 40 }; 41 42 43 #endif 44 45