fork download
  1. #include <iostream>
  2. #include <inttypes.h>
  3.  
  4. class Test{
  5. public:
  6. static const uint32_t Magic = 0x1123;
  7. };
  8.  
  9. class DataStream{
  10. public:
  11. template<typename T>
  12. DataStream& operator <<( const T& value )
  13. {
  14. std::cout << value << std::endl;
  15. return *this;
  16. }
  17. };
  18.  
  19. int main()
  20. {
  21. DataStream s;
  22.  
  23. uint32_t a = Test::Magic; // ok
  24. bool compare = ( a == Test::Magic ); // ok
  25. s << compare;
  26. s << a;
  27. s << Test::Magic; // fail
  28.  
  29. return 0;
  30. }
Compilation error #stdin compilation error #stdout 0s 15240KB
stdin
Standard input is empty
compilation info
/home/BpQ3HM/prog-331b5c.o: In function `main':
prog.cpp:(.text+0xc2): undefined reference to `Test::Magic'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
stdout
Standard output is empty