Click here to Skip to main content
15,917,005 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionC++ Generic Autorun app ? Pin
Marc Piulachs24-Mar-04 4:38
Marc Piulachs24-Mar-04 4:38 
AnswerRe: C++ Generic Autorun app ? Pin
jhwurmbach24-Mar-04 5:34
jhwurmbach24-Mar-04 5:34 
QuestionHow to use CryptExportkey blob Pin
chakra_r24-Mar-04 3:32
chakra_r24-Mar-04 3:32 
General_control87 and signal(SIGFPE....) Pin
prcarp24-Mar-04 3:03
prcarp24-Mar-04 3:03 
GeneralGetDIBits and 98 Problem Pin
Ceri24-Mar-04 2:43
Ceri24-Mar-04 2:43 
GeneralHelp - CPrintDialog as a child Pin
Jason Carter24-Mar-04 2:41
Jason Carter24-Mar-04 2:41 
GeneralOverloading operator [ ] Pin
Imtiaz Murtaza24-Mar-04 0:58
Imtiaz Murtaza24-Mar-04 0:58 
GeneralRe: Overloading operator [ ] Pin
Mike Dimmick24-Mar-04 2:20
Mike Dimmick24-Mar-04 2:20 
IIRC, the rules of C++ say that if two functions differ only by const, the non-const version is preferred for a non-const object.

If foo was const, the first assignment would call const int MyClass::operator[](int) const while the second wouldn't compile (the error would probably say something like "'const int' is not an l-value").

C++ doesn't know the context of an array access, so you return a reference to the object to be assigned to if you want to allow assignment. If you want to be able to control assignment (e.g. inspect the value before assigning it), you typically need to return a proxy object from operator[]. The proxy object overloads operator= and is also convertible to the contained type (in this case, you'd probably supply operator int). You would place your 'setter' logic in operator=.

Stability. What an interesting concept. -- Chris Maunder
GeneralRe: Overloading operator [ ] Pin
David Crow24-Mar-04 2:36
David Crow24-Mar-04 2:36 
GeneralRe: Overloading operator [ ] Pin
Ryan Binns24-Mar-04 3:44
Ryan Binns24-Mar-04 3:44 
GeneralSystem performance comparison Pin
Shree24-Mar-04 0:55
Shree24-Mar-04 0:55 
GeneralMFC Views Documents, and Modal windows :_-) Pin
_psh_24-Mar-04 0:41
_psh_24-Mar-04 0:41 
QuestionWhen does it occur the worst case in Quicksort algorithm ? Pin
nguyen_nd24-Mar-04 0:34
nguyen_nd24-Mar-04 0:34 
AnswerRe: When does it occur the worst case in Quicksort algorithm ? Pin
Maximilien24-Mar-04 0:54
Maximilien24-Mar-04 0:54 
AnswerRe: When does it occur the worst case in Quicksort algorithm ? Pin
David Crow24-Mar-04 2:43
David Crow24-Mar-04 2:43 
GeneralEDK Pin
viliam24-Mar-04 0:03
viliam24-Mar-04 0:03 
GeneralRe: EDK Pin
Mike Dimmick24-Mar-04 2:23
Mike Dimmick24-Mar-04 2:23 
GeneralRe: EDK Pin
viliam24-Mar-04 3:44
viliam24-Mar-04 3:44 
GeneralATL Service Tutorial Pin
Anonymous23-Mar-04 23:49
Anonymous23-Mar-04 23:49 
Generalpocket pc Recent Programs Pin
venkigdl23-Mar-04 23:29
venkigdl23-Mar-04 23:29 
GeneralRe: pocket pc Recent Programs Pin
Cedric Moonen23-Mar-04 23:33
Cedric Moonen23-Mar-04 23:33 
QuestionHow to get most significant digit ? Pin
Cedric Moonen23-Mar-04 22:55
Cedric Moonen23-Mar-04 22:55 
AnswerRe: How to get most significant digit ? Pin
Pedro Ruiz23-Mar-04 23:17
Pedro Ruiz23-Mar-04 23:17 
GeneralRe: How to get most significant digit ? Pin
Cedric Moonen23-Mar-04 23:26
Cedric Moonen23-Mar-04 23:26 
AnswerRe: How to get most significant digit ? Pin
Cedric Moonen23-Mar-04 23:17
Cedric Moonen23-Mar-04 23:17 

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.