Click here to Skip to main content
15,879,535 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Generalneed help in c program Pin
Henry soon24-Jul-02 3:14
sussHenry soon24-Jul-02 3:14 
GeneralRe: need help in c program Pin
benjymous24-Jul-02 3:56
benjymous24-Jul-02 3:56 
GeneralRe: need help in c program Pin
henry soon24-Jul-02 4:02
susshenry soon24-Jul-02 4:02 
GeneralRe: need help in c program Pin
henrysoon24-Jul-02 4:04
henrysoon24-Jul-02 4:04 
GeneralRe: need help in c program Pin
benjymous24-Jul-02 4:35
benjymous24-Jul-02 4:35 
GeneralConstructors throwing exceptions cont. Pin
tom7624-Jul-02 3:13
tom7624-Jul-02 3:13 
GeneralRe: Constructors throwing exceptions cont. Pin
Tomasz Sowinski24-Jul-02 3:21
Tomasz Sowinski24-Jul-02 3:21 
GeneralRe: Constructors throwing exceptions cont. Pin
tom7624-Jul-02 4:02
tom7624-Jul-02 4:02 
I've just found that the following puts the aplication into an assertion loop.


// Default constructor<br />
AddPrinterDialog::AddPrinterDialog()<br />
{<br />
    try<br />
    {<br />
        mAddPrinterDialogPointer = new AddPrinterDialog;<br />
    }<br />
    catch(...)<br />
    {<br />
<br />
    }<br />
<br />
}



All I want is some code that has a constructor throwing an exception if it fails. It seems I can't use the current code.

That webpage was interesting, but the code was v.confusing. For example
<br />
// Example 1(a): Constructor function-try-block<br />
//<br />
C::C()<br />
try<br />
  : A ( /*...*/ ) // optional initialization list<br />
  , b_( /*...*/ )<br />
{<br />
}<br />
catch( ... )<br />
{<br />
  // We get here if either A::A() or B::B() throws.<br />
<br />
  // If A::A() succeeds and then B::B() throws, the<br />
  // language guarantees that A::~A() will be called<br />
  // to destroy the already-created A base subobject<br />
  // before control reaches this catch block.<br />
}<br />
<br />

is all very well but what if you're NOT inheriting? Or you don't care about parent classes (say you derived from an MFC class).

All I want is a default constructor throwing an exception. But I have no idea how you test for an object's existence, especially inside the default constructor's body as the object won't have been created yet.

Obseve everything, remember more...
GeneralRe: Constructors throwing exceptions cont. Pin
Tomasz Sowinski24-Jul-02 4:10
Tomasz Sowinski24-Jul-02 4:10 
GeneralRe: Constructors throwing exceptions cont. Pin
tom7624-Jul-02 4:28
tom7624-Jul-02 4:28 
GeneralRe: Constructors throwing exceptions cont. Pin
Tomasz Sowinski24-Jul-02 4:34
Tomasz Sowinski24-Jul-02 4:34 
GeneralRe: Constructors throwing exceptions cont. Pin
tom7624-Jul-02 4:51
tom7624-Jul-02 4:51 
GeneralRe: Constructors throwing exceptions cont. Pin
Tomasz Sowinski24-Jul-02 5:03
Tomasz Sowinski24-Jul-02 5:03 
GeneralRe: Constructors throwing exceptions cont. Pin
Philippe Mori24-Jul-02 8:16
Philippe Mori24-Jul-02 8:16 
GeneralRe: Constructors throwing exceptions cont. Pin
JohnnyG24-Jul-02 10:45
JohnnyG24-Jul-02 10:45 
GeneralRe: Constructors throwing exceptions cont. Pin
tom7624-Jul-02 21:51
tom7624-Jul-02 21:51 
GeneralGOT IT! Pin
tom7624-Jul-02 23:18
tom7624-Jul-02 23:18 
Generalhelp needed Pin
OmarLodhi24-Jul-02 3:00
OmarLodhi24-Jul-02 3:00 
GeneralRe: help needed Pin
Philippe Mori24-Jul-02 8:18
Philippe Mori24-Jul-02 8:18 
GeneralVisual C++ optimize Pin
Hiusing24-Jul-02 2:47
Hiusing24-Jul-02 2:47 
GeneralCHtmlView printing doubt - (tech level - newbie) Pin
Nish Nishant24-Jul-02 1:55
sitebuilderNish Nishant24-Jul-02 1:55 
GeneralRe: CHtmlView printing doubt - One line solution :-) Pin
Nish Nishant24-Jul-02 2:32
sitebuilderNish Nishant24-Jul-02 2:32 
GeneralHINSTANCE hPrevious Pin
slah24-Jul-02 1:21
slah24-Jul-02 1:21 
GeneralRe: HINSTANCE hPrevious Pin
Nish Nishant24-Jul-02 1:25
sitebuilderNish Nishant24-Jul-02 1:25 
GeneralRe: HINSTANCE hPrevious Pin
Atlence24-Jul-02 5:31
Atlence24-Jul-02 5:31 

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.