Archive for September 22nd, 2007

C++ Hating

Saturday, September 22nd, 2007

I believed I had this beautiful set of numbers. Then reality struck and they weren't actually there. On one hand, having fake but nice numbers is bad, on the other hand, those numbers were really pretty. And now I sit around reading and thinking about Haskell and hating on C++. Who would have known that j would differ in

 
  std::vector<int> something[numelts];
  something[7].push_back(2);
  int j = something[7][0];
 

and

 
  std::vector<int> something[numelts];
  something[7].push_back(2);
  int j = (something[7])[0];
 

.
The later is correct, the first is wrong, C++ seems to be treating unparenthisized things as normal array lookups, while the parenthisized thing leads to it using operator[] from vector.

panda