fork(1) download
  1. #include <iostream>
  2.  
  3. void ptrFunc( const int* p )
  4. {
  5. if ( p )
  6. {
  7. std::cout << "*p == " << *p << std::endl;
  8. }
  9. }
  10.  
  11. void refFunc( const int& i )
  12. {
  13. std::cout << "(ref)i == " << i << std::endl;
  14. }
  15.  
  16. void valueFunc( int i )
  17. {
  18. std::cout << "i == " << i << std::endl;
  19. }
  20.  
  21. template< class T >
  22. const T* addrtemp(const T& arg)
  23. {
  24. return reinterpret_cast<T*>(
  25. &const_cast<char&>(
  26. reinterpret_cast<const volatile char&>(arg)));
  27. }
  28.  
  29. int main()
  30. {
  31. valueFunc( int() );
  32. refFunc( int() );
  33. ptrFunc( addrtemp(int()) );
  34. return 0;
  35. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
i == 0
(ref)i == 0
*p == 0