fork download
  1. #include <iostream>
  2.  
  3. const int MAX_SIZE = 3;
  4.  
  5. class BigInt
  6. {
  7. public:
  8. BigInt( const char *value );
  9. friend std::ostream &operator<<( std::ostream &stm , const BigInt &bi );
  10. private:
  11. int value[ MAX_SIZE ];
  12. };
  13.  
  14. BigInt::BigInt( const char *value )
  15. {
  16. for( int i = 0; i < MAX_SIZE; ++i )
  17. {
  18. //this->value[ i ] = -'0' + *value++;
  19. this->value[ i ] = *value - '0';
  20. ++value;
  21. }
  22. }
  23.  
  24. std::ostream &operator<<( std::ostream &stm , const BigInt &bi )
  25. {
  26. for( int i = 0; i < MAX_SIZE; ++i )
  27. {
  28. stm << bi.value[ i ];
  29. }
  30. return( stm );
  31. }
  32.  
  33. int main()
  34. {
  35. //char array[] = "123";
  36. //const char* value = "123";
  37.  
  38. //BigInt bi1( value );
  39.  
  40. //BigInt bi1( array );
  41. BigInt bi1( "123" );
  42. std::cout << bi1 << std::endl;
  43. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
123