fork(2) download
  1. #include <iostream>
  2.  
  3. template <class IType> class BitArray;
  4. template <class IType> std::ostream& operator<<(std::ostream&, const BitArray<IType>&);
  5. template <class IType> std::istream& operator>>(std::istream&, BitArray<IType>&);
  6.  
  7.  
  8. template < class IType = unsigned int >
  9. class BitArray {
  10. friend std::ostream& operator<< <>(std::ostream&, const BitArray&);
  11. friend std::istream& operator>> <>(std::istream&, BitArray&);
  12. private:
  13. IType value = {};
  14. };
  15.  
  16. template <class IType>
  17. std::ostream& operator<<(std::ostream& os, const BitArray<IType>& b)
  18. {
  19. return os << b.value;
  20. }
  21.  
  22. template <class IType>
  23. std::istream& operator>>(std::istream& os, BitArray<IType>& b)
  24. {
  25. return os >> b.value;
  26. }
  27.  
  28. int main()
  29. {
  30. BitArray<int> b;
  31. std::cin >> b;
  32. std::cout << b << std::endl;
  33. return 0;
  34. }
  35.  
Success #stdin #stdout 0s 3300KB
stdin
42
stdout
42