Click here to Skip to main content
15,888,610 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Answer... and to see the difference ... Pin
Mircea Puiu14-Nov-05 5:43
Mircea Puiu14-Nov-05 5:43 
GeneralRe: ... and to see the difference ... Pin
Rajesh R Subramanian14-Nov-05 17:18
professionalRajesh R Subramanian14-Nov-05 17:18 
GeneralRe: ... and to see the difference ... Pin
AORD14-Nov-05 18:21
AORD14-Nov-05 18:21 
QuestionWhy CListView do not inherit from CListCtrl Pin
white jungle13-Nov-05 20:49
white jungle13-Nov-05 20:49 
AnswerRe: Why CListView do not inherit from CListCtrl Pin
YaronNir14-Nov-05 1:37
YaronNir14-Nov-05 1:37 
AnswerRe: Why CListView do not inherit from CListCtrl Pin
Sheng Jiang 蒋晟14-Nov-05 19:24
Sheng Jiang 蒋晟14-Nov-05 19:24 
Questiondiff b/w LUID and SID Pin
sunit513-Nov-05 20:25
sunit513-Nov-05 20:25 
AnswerRe: diff b/w LUID and SID Pin
sunit513-Nov-05 21:00
sunit513-Nov-05 21:00 
QuestionIn MFC model less Dialogbox Pin
vikas amin13-Nov-05 19:24
vikas amin13-Nov-05 19:24 
AnswerRe: In MFC model less Dialogbox Pin
Mircea Puiu13-Nov-05 20:13
Mircea Puiu13-Nov-05 20:13 
AnswerRe: In MFC model less Dialogbox Pin
*Dreamz13-Nov-05 20:20
*Dreamz13-Nov-05 20:20 
GeneralRe: In MFC model less Dialogbox Pin
vikas amin13-Nov-05 21:04
vikas amin13-Nov-05 21:04 
Questionuse object itself as key in stl map Pin
yccheok13-Nov-05 19:18
yccheok13-Nov-05 19:18 
I have an object which will be used as a key in stl map. Although I had overridden all the comparison operator (==, >, <, >=, <=), the vc++ compiler still makes complain on:

Compiling...
point.cpp
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\functional(86) : error C2678: binary '<' : no operator defined which takes a left-hand operand of type 'const class Point' (or there is no acceptable conversion)
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\functional(86) : while compiling class-template member function 'bool __thiscall std::less<class point="">::operator ()(const class Point &,const class Point &) const'
Error executing cl.exe.

point.exe - 1 error(s), 0 warning(s)

Any suggestion/ advice is very much appreciated.

cheok


#include
#include <assert.h>

using namespace std;

class Point {
public:
Point() {
this->x = 0;
this->y = 0;
}

Point(int x, int y) {
this->x = x;
this->y = y;
}

Point(const Point &p) {
this->x = p.x;
this->y = p.y;
}

Point& operator=(const Point &p) {
this->x = p.x;
this->y = p.y;

return *this;
}

bool operator== (const Point &p) {
return (this->x == p.x && this->y == p.y);
}

bool operator> (const Point &p) {
// For simplicity, we ignore x.
//
return (this->y > p.y);
}

bool operator< (const Point &p) {
// For simplicity, we ignore x.
//
return (this->y < p.y);
}

bool operator<= (const Point &p) {
// For simplicity, we ignore x.
//
return (this->y <= p.y);
}

bool operator>= (const Point &p) {
// For simplicity, we ignore x.
//
return (this->y >= p.y);
}

private:
int x;
int y;
};

int main() {
map<point, point=""> m;

Point p1(100, 100);
Point p2(100, 100);

if(m.find(p1) == m.end()) {
m[p1] = p1;
}

// Although p1 and p2 are different objects,
// their content is the same through comparison on their
// private member variables x and y.
//
// Hence, p2 shouldn't be inserted into the map.
//
if(m.find(p2) == m.end()) {
m[p2] = p2;
assert(0);
}

return 1;
}
AnswerRe: use object itself as key in stl map Pin
Garth J Lancaster13-Nov-05 19:54
professionalGarth J Lancaster13-Nov-05 19:54 
AnswerRe: use object itself as key in stl map Pin
*Dreamz13-Nov-05 20:39
*Dreamz13-Nov-05 20:39 
GeneralRe: use object itself as key in stl map Pin
yccheok13-Nov-05 23:05
yccheok13-Nov-05 23:05 
Questionhow to make arrow keys work for help button in Cpropertysheet in MFC in VC++ Pin
simhadri13-Nov-05 18:56
simhadri13-Nov-05 18:56 
AnswerRe: how to make arrow keys work for help button in Cpropertysheet in MFC in VC++ Pin
Cool Ju13-Nov-05 22:05
Cool Ju13-Nov-05 22:05 
GeneralRe: how to make arrow keys work for help button in Cpropertysheet in MFC in VC++ Pin
simhadri22-Nov-05 17:10
simhadri22-Nov-05 17:10 
QuestionI'm Sick Of GetPixel, Any Alternative? Pin
Owner drawn13-Nov-05 18:18
Owner drawn13-Nov-05 18:18 
AnswerRe: I'm Sick Of GetPixel, Any Alternative? Pin
James Brown13-Nov-05 20:20
James Brown13-Nov-05 20:20 
QuestionThread Blocking Pin
Nishad S13-Nov-05 18:08
Nishad S13-Nov-05 18:08 
AnswerRe: Thread Blocking Pin
22491713-Nov-05 23:15
22491713-Nov-05 23:15 
GeneralRe: Thread Blocking Pin
Nishad S13-Nov-05 23:27
Nishad S13-Nov-05 23:27 
AnswerRe: Thread Blocking Pin
Steen Krogsgaard14-Nov-05 2:14
Steen Krogsgaard14-Nov-05 2:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.