FIX: dbDao's CdbException Uses Private ConstructorLast reviewed: September 19, 1997Article ID: Q141447 |
3.00
WINDOWS NT
kbprg kbcode kbbuglist kbfixlist
The information in this article applies to:
SYMPTOMSIt is difficult to explicitly throw a CdbException from the dbDAO class library. It is possible, depending on how the exception class is thrown, to generate this error:
C2248: 'CdbException::CdbException' : cannot access private member declared in class 'CdbException' CAUSEThis is because the constructor for the class is implicitly private. It does not inherit, nor are any classes inherited from CdbException, and it does not define any friends for the class. The dbDao classes, however, are successfully able to throw the exception, but only because of another bug within the Visual C++ 4.0 compiler that allows you to throw a temporary instance of a class with only a private constructor.
RESOLUTIONThe error is generated if you declare an instance of CdbException and then attempt to throw it.
HRESULT hr; CdbException myException( hr ); throw myException; // Generates error C2248However, you can successfully throw the instance if you throw a temporary instance of CdbException.
HRESULT hr; throw CdbException( hr );Now it is possible to catch this exception using C++ exception handling.
STATUSMicrosoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This bug was corrected in Visual C++ 32- bit Edition version 4.1.
|
Additional reference words: 3.00 4.00 4.10 vcbuglist400 vcfixlist410
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |