Click here to Skip to main content
15,914,419 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: raw socket in Windows XP Pin
eagleboy17-Jul-05 19:37
eagleboy17-Jul-05 19:37 
GeneralRe: raw socket in Windows XP Pin
yanping wang17-Jul-05 20:47
yanping wang17-Jul-05 20:47 
GeneralLPTHREAD_START_ROUTINE related Pin
rajandpayal17-Jul-05 16:13
rajandpayal17-Jul-05 16:13 
GeneralRe: LPTHREAD_START_ROUTINE related Pin
Jose Lamas Rios18-Jul-05 4:44
Jose Lamas Rios18-Jul-05 4:44 
QuestionWhere do you initialize Form Controls? Pin
Freddie Code17-Jul-05 15:58
Freddie Code17-Jul-05 15:58 
AnswerRe: Where do you initialize Form Controls? Pin
Jose Lamas Rios17-Jul-05 16:27
Jose Lamas Rios17-Jul-05 16:27 
GeneralC2676 and KB 814455 and overloading Pin
TedCB17-Jul-05 14:22
TedCB17-Jul-05 14:22 
GeneralRe: C2676 and KB 814455 and overloading Pin
Jose Lamas Rios17-Jul-05 16:16
Jose Lamas Rios17-Jul-05 16:16 
TedCB wrote:
The functions (in m_apm.h) causing the difficulty are
MAPM operator--() /* Prefix decrement operator */
{return *this = *this-MM_One;}
and
MAPM &operator-=(const MAPM &m) {*this = *this-m;return *this;}


Member functions receive an implicit parameter this that represents the object on which the member was called. A member class operator defined as:

MAPM operator--() /* Prefix decrement operator */
{
   return *this = *this-MM_One;
}

is an unary operator that is acting only on the implicit parameter this.

If you want to, as the MS article suggests, move it out of the class scope, you need to declare it as a friend non-member function, and the implicit parameter needs to become explicit. In the function body, the references to this need to be changed to references to the now explicit parameter. You should write something like this:

class MAPM
{
   // Whatever else it's in the class declaration
   // [...]
 
   friend MAPM operator--(MAPM& m);
};
 
MAPM operator--(MAPM& m)
{
   return m = m - MM_One;
}

Similarly, the operator-= is a binary operator, receiving first the implicit this and then the explicit const MAPM& m. So, as before, if you want to move it out of the class scope, you'll need to convert the implicit first parameter this to an explicit parameter. Something like this (now showing the move of both operators out of the class):

class MAPM
{
   // Whatever else it's in the class declaration
   // [...]
 
   friend MAPM operator--(MAPM& m);
 
   friend MAPM& operator-=(MAPM& m1, const MAPM& m2);
};
 
MAPM operator--(MAPM& m)
{
   return m = m - MM_One;
}
 
MAPM& operator-=(MAPM &m1, const MAPM& m2)
{
   m1 = m1 - m2;
   return m1;
}

Hope that helps,


--
jlr
http://jlamas.blogspot.com/[^]
GeneralRe: C2676 and KB 814455 and overloading Pin
TedCB17-Jul-05 17:13
TedCB17-Jul-05 17:13 
GeneralRe: C2676 and KB 814455 and overloading Pin
Jose Lamas Rios17-Jul-05 17:29
Jose Lamas Rios17-Jul-05 17:29 
GeneralHiding process in task manager Pin
Anonymous17-Jul-05 10:35
Anonymous17-Jul-05 10:35 
GeneralRe: Hiding process in task manager Pin
Toby Opferman17-Jul-05 13:00
Toby Opferman17-Jul-05 13:00 
Generaldoesn't allowing to go focus out of the window and traping the ctrl+alt+del message Pin
Anonymous17-Jul-05 10:32
Anonymous17-Jul-05 10:32 
GeneralRe: doesn't allowing to go focus out of the window and traping the ctrl+alt+del message Pin
Toby Opferman17-Jul-05 13:00
Toby Opferman17-Jul-05 13:00 
GeneralRe: doesn't allowing to go focus out of the window and traping the ctrl+alt+del message Pin
Trollslayer17-Jul-05 21:57
mentorTrollslayer17-Jul-05 21:57 
Generalexecuting program before the login screen appears Pin
Anonymous17-Jul-05 10:20
Anonymous17-Jul-05 10:20 
GeneralRe: executing program before the login screen appears Pin
David Crow17-Jul-05 12:27
David Crow17-Jul-05 12:27 
GeneralRe: executing program before the login screen appears Pin
Aamir Butt18-Jul-05 2:22
Aamir Butt18-Jul-05 2:22 
GeneralRe: executing program before the login screen appears Pin
David Crow18-Jul-05 2:34
David Crow18-Jul-05 2:34 
QuestionHow do I reset the default values for opening the "file folder"? Pin
Justice117-Jul-05 9:07
sussJustice117-Jul-05 9:07 
AnswerRe: How do I reset the default values for opening the "file folder"? Pin
PravinSingh18-Jul-05 0:22
PravinSingh18-Jul-05 0:22 
GeneralRe: How do I reset the default values for opening the "file folder"? Pin
Justice118-Jul-05 14:14
sussJustice118-Jul-05 14:14 
Questionhow to send WM_ to other Apps Pin
josephvan17-Jul-05 5:38
josephvan17-Jul-05 5:38 
AnswerRe: how to send WM_ to other Apps Pin
CodeBeetle17-Jul-05 9:28
CodeBeetle17-Jul-05 9:28 
GeneralE Mail module in VC Pin
Usman Tasleem Akshaf17-Jul-05 4:57
Usman Tasleem Akshaf17-Jul-05 4:57 

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.