Advertisement
WeltEnSTurm

Untitled

Nov 25th, 2011
363
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1.  
  2. struct stupidCastTest {
  3.     float* data;
  4.    
  5.     operator float* () {
  6.         return data;
  7.     }
  8.    
  9.     float& operator [] (long idx) {
  10.         return data[idx];
  11.     }
  12. }
  13.  
  14. int main () {
  15.     stupidCastTest instance;
  16.     instance.data = new float[10];
  17.     instance[3] = 5; // by logic it would call the overloaded operator,
  18.                      // but ISO says it is not clear whether it should
  19.                      // call ((float*)instance)[3] or instance[3].
  20.     return 0;
  21. }
  22.  
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement