Click here to Skip to main content
15,923,681 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: SQL Server Connection Fails Pin
Blake Miller18-Jul-03 5:36
Blake Miller18-Jul-03 5:36 
GeneralCString problem removing chars Pin
si_6917-Jul-03 22:36
si_6917-Jul-03 22:36 
GeneralRe: CString problem removing chars Pin
Dominik Reichl17-Jul-03 23:31
Dominik Reichl17-Jul-03 23:31 
GeneralRe: CString problem removing chars Pin
RChin18-Jul-03 4:25
RChin18-Jul-03 4:25 
Generalwindow does not hide if it is minimized and ShowWindow(SW_HIDE) is called Pin
FASTian17-Jul-03 22:05
FASTian17-Jul-03 22:05 
GeneralGDI+ and Effect class' Pin
cmk17-Jul-03 22:02
cmk17-Jul-03 22:02 
GeneralAbout some terms Pin
FlyingDancer17-Jul-03 21:38
FlyingDancer17-Jul-03 21:38 
GeneralRe: About some terms Pin
Mike Dimmick17-Jul-03 22:44
Mike Dimmick17-Jul-03 22:44 
DECLARE_DYNAMIC and IMPLEMENT_DYNAMIC are MFC macros. You must use them if you want MFC's DYNAMIC_DOWNCAST macro, the RUNTIME_CLASS macro, and the IsKindOf method to work. Your class must be derived from CObject.

If using a newish version of C++ (VC 6.0 and later, IIRC), and not interfacing with older MFC code that uses these macros, I suggest sticking to the standard C++ dynamic_cast cast operator and the typeid operator. Note that these can't be used on Windows CE prior to version 4.0, as they require runtime library support that isn't available on CE 3.0 and below.

If you want to use DECLARE_DYNCREATE or DECLARE_SERIAL in a derived class, you must use at least DECLARE_DYNAMIC in your base class (otherwise your code will not compile). DECLARE_DYNCREATE enables dynamic creation of objects by MFC: this is required by the document/view framework for creation of document and view objects. DECLARE_SERIAL provides a default implementation of an operator << and operator >> for your class - this is used for object serialisation to a CArchive.

See the documentation topic CObject Class: Deriving a Class from CObject[^] for more information on these macros.

Item 2:

The operator keyword introduces a method that replaces the operator symbol mentioned: i.e. operator= replaces the normal behaviour of the = operator. If operator= is written as a member function, it will be used if the left-hand side of the assignment expression is of the type the operator= is a member of, and the right-hand side is of the type mentioned in the argument. Assuming that this operator= is defined in CStudent, this operator= will be used whenever one CStudent object is assigned to another.

The use of const here indicates that the return value of operator= cannot be modified by the caller, in the same way that the const on the argument indicates that s cannot be modified within the function.

Style note: In accordance with the guidance of 'do as the ints do', operator= should return a CStudent&, not a const CStudent&. See Effective C++[^] for more guidelines on implementing operator=.

Item 3:

operator== has much the same meaning as in #2, but this time we're replacing the == equality operator. We're comparing this against s.

The const at the end of the declaration says something different. It tells the compiler that this function may be called on CStudent objects that are const, i.e. they're read-only. Functions declared const may not modify member variables, unless they're declared mutable.
GeneralRe: About some terms Pin
FlyingDancer17-Jul-03 23:35
FlyingDancer17-Jul-03 23:35 
GeneralRepeat Button Pin
shinay17-Jul-03 21:13
shinay17-Jul-03 21:13 
Questionhow to use a com dll Pin
vcseeker17-Jul-03 20:49
vcseeker17-Jul-03 20:49 
AnswerRe: how to use a com dll Pin
si_6917-Jul-03 22:48
si_6917-Jul-03 22:48 
GeneralUse CRichEditCtrl with CFormView Pin
CS42917-Jul-03 20:41
CS42917-Jul-03 20:41 
GeneralIdentification of disks from pathnames Pin
Anonymous17-Jul-03 20:39
Anonymous17-Jul-03 20:39 
GeneralRe: Identification of disks from pathnames Pin
Neville Franks17-Jul-03 22:28
Neville Franks17-Jul-03 22:28 
GeneralMFC vs. C# Pin
DaveE9th17-Jul-03 20:33
DaveE9th17-Jul-03 20:33 
GeneralRe: MFC vs. C# Pin
Mike Dimmick17-Jul-03 22:55
Mike Dimmick17-Jul-03 22:55 
GeneralRe: MFC vs. C# Pin
Anonymous18-Jul-03 7:39
Anonymous18-Jul-03 7:39 
GeneralRe: MFC vs. C# Pin
DaveE9th18-Jul-03 7:44
DaveE9th18-Jul-03 7:44 
GeneralRe: MFC vs. C# Pin
Bob Stanneveld18-Jul-03 7:57
Bob Stanneveld18-Jul-03 7:57 
GeneralRe: MFC vs. C# Pin
DaveE9th18-Jul-03 21:07
DaveE9th18-Jul-03 21:07 
AnswerRe: basetsd.h? Pin
John M. Drescher17-Jul-03 20:21
John M. Drescher17-Jul-03 20:21 
GeneralRe: basetsd.h? Pin
DaveE9th17-Jul-03 20:39
DaveE9th17-Jul-03 20:39 
GeneralRe: basetsd.h? Pin
John M. Drescher18-Jul-03 3:59
John M. Drescher18-Jul-03 3:59 
GeneralRe: basetsd.h? Pin
DaveE9th18-Jul-03 7:45
DaveE9th18-Jul-03 7:45 

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.