The information in this article applies to:
SYMPTOMSWhen you implement a class derived from CObject and your code is written so that the copy constructor or assignment operator for the class needs to be called, the compiler may report errors similar to the following: You can reproduce the problem by compiling the sample code in the "RESOLUTION" section, below. NOTE: Using Visual C++, 32-bit Edition, versions 2.x and 4.0, the sample code shown in this article generates the following error messages:
CAUSEThe reason for the compiler errors is that CObject declares a private copy constructor and assignment operator in the AFX.H file. The compiler does not generate a default copy constructor and assignment operator for the CObject-derived class because of this. Because the compiler does not find these functions declared in the class, it reports the errors. RESOLUTIONTo avoid the compiler errors, you need to implement a copy constructor and assignment operator for the CObject-derived class. This is illustrated in the sample code below. You can avoid the errors by uncommenting the lines indicated in the sample code. Sample Code
REFERENCES
"Visual C++ and C/C++, version 7.0 Language Reference" manuals,
Section 11.7, "Copying Class Objects."
Additional query words: 7.00 1.00 1.50 2.00 2.10 2.50 1.51 1.52 2.51 3.00 3.10 4.00 arguments
Keywords : kbnokeyword kbMFC kbVC |
Last Reviewed: February 2, 2000 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |