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

C / C++ / MFC

 
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 
GeneralRe: Overloading operator [ ] Pin
David Crow24-Mar-04 2:36
David Crow24-Mar-04 2:36 
From what I can tell, you only need one of the overridden methods. The second one can be used on either the left or the right side of an assignment statement. Consider this example:

class MyClass
{            
public:
    MyClass()
    {
        arr[0] = 2;
        arr[1] = 4;
        arr[2] = 6;
    }
 
    int& operator[](const int i )
    {
        return arr[i];
    }
 
    int arr[3];
};
 
MyClass foo;    
int j = 0,
    i = foo[j]; // assigns the value 2 to i
foo[2] = i;     // assigns the value 2 to the third item in the array
The reason has to do with the function returning a reference to arr. It's being treated as if you had written:

MyClass foo;    
int j = 0,
    i = foo.arr[j];
foo.arr[2] = i;



"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)


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 
GeneralRe: How to get most significant digit ? Pin
Prakash Nadar23-Mar-04 23:19
Prakash Nadar23-Mar-04 23:19 

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.