Penguin

Differences between version 4 and previous revision of C++Notes.

Other diffs: Previous Major Revision, Previous Author, or view the Annotated Edit History

Newer page: version 4 Last edited on Thursday, September 23, 2004 3:26:56 pm by PerryLorier Revert
Older page: version 3 Last edited on Thursday, September 23, 2004 3:26:38 pm by PerryLorier Revert
@@ -24,10 +24,10 @@
  
  std::map<foo_t,int*> foo_map; 
  
 ... 
- foo_map[foo]=new int;  
- *foo_map[foo]=6; 
+ foo_map[ [foo]=new int;  
+ *foo_map[ [foo]=6; 
  
 And this code crashed. The reason was that my operator < was wrong. it voilated the contact of a < operator. I changed the "bool operator <" to "int cmp" and then defined operator <: 
  bool operator <(const foo_t &a, const foo_t &b) { return cmp(a,b) < 0; } 
 I also recommend adding some assert(3)'s to verify that your operators don't voilate the rules at runtime.