This has been bugging me for about a week now. It's sort of a C++ question but since it's in the context of MFC, I figured I'd drop it here.
Now I know the '->' operator is for referencing members and member functions of a class or struct referenced by a pointer. I know the '.' is used to reference members and member functions of a class or struct represented by an object as aposed to a pointer.
Now that may have been confusing but the code I have here should clear it up. The book I'm studying on MFC has described accessing the same types of objects in BOTH ways in differing pieces of code but never explains why he chose to access it in that way.
And now this way...Code:CDialog dlg(IDD_ABOUTDIALOG, this); dlg.DoModal();
Now I know in the second instance the dialog was created dynamically via the 'new' keyword, but what I don't understand is why he made dlg a pointer rather then an object? He's also done this with CPaintDC as well (not to mention CPen, CBrush and a few others) and I can't get a handle on the reason behind the variations.Code:CDialog* dlg = new CDialog(IDD_ABOUTDIALOG, this); dlg->DoModal(); delete dlg;
Any help would sure be appreaciated.
P.S. C++ and MFC are both new to me (2 months now) Aside from the dumb question, does it sound like I'm getting a handle on this stuff or does it sound like I'm still completely lost?