fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <cstdlib>
  4. #include <cstdio>
  5.  
  6. enum Types { NONE = -1 , INT , FLOAT , STRING };
  7.  
  8. class Value{
  9. protected:
  10. Types __type;
  11. public:
  12. Types __datatype__(){
  13. return (this->__type);
  14. }
  15. virtual const void * __getData__() = 0;
  16. };
  17.  
  18. class INTEGER : public Value
  19. {
  20. long int payload;
  21.  
  22. public:
  23. INTEGER(int value=0):Value(){
  24. this->__type = INT;
  25. this->payload = value;
  26. }
  27.  
  28. int cInt(){
  29. return this->payload;
  30. }
  31.  
  32. virtual const void * __getData__(){
  33. return ( void * ) payload;
  34. }
  35.  
  36. void operator= ( long int &val ){
  37. this->payload = val;
  38. }
  39.  
  40. friend std::ostream& operator<< ( std::ostream& os, INTEGER const& v ){
  41. os<<v.payload;
  42. return os;
  43. }
  44. };
  45.  
  46. int main()
  47. {
  48. INTEGER i1(2);
  49. std::cout<<i1;
  50. }
  51.  
Success #stdin #stdout 0s 2852KB
stdin
Standard input is empty
stdout
2