-

   rss_forum_sources_ru

 - e-mail

 

 -

 LiveInternet.ru:
: 29.07.2007
:
:
: 80

:


catch (std::bad_alloc& ba) MFC .

, 14 2020 . 15:48 +
a_n_y_a: std::bad_alloc , MFC, . .
:
    #include "stdafx.h"
    #include "MyInt.hpp"
    #include
    #include
    #include
    using namespace std;
    int main()
    {
    std::locale Loc = std::locale::global(std::locale("russian"));
    char *buf = NULL, *buf1 = NULL;
    try
    {
    buf = new char[_I64_MAX_MY - 5];
    buf1 = new char[_I64_MAX_MY - 5];
    }
    catch (std::bad_alloc)
    {
    wcout<< _T(" std::bad_alloc \n");
    }
    catch (...)
    {
    wcout << _T("std::bad_alloc \n");
    };
    int i;
    wcout << _T(" i=");
    wcin >> i;
    if (buf != NULL) delete[]buf;
    if (buf1 != NULL) delete[]buf1;
    return 0;
    };

_I64_MAX_MY MAX_MY_INT , , x86 x64. .

:
    void CMyThrowCatchDlg::OnBnClickedButton1()
    {
    // TODO: Add your control notification handler code here
    char *buf = NULL, *buf1 = NULL;
    try
    {
    buf = new char[MAX_MY_INT - 5];
    buf1 = new char[MAX_MY_INT - 5];
    }
    catch (CMemoryException& mex)
    {
    CString s;
    s = _T(" CMemoryException ");
    AfxMessageBox(s);
    }
    catch (std::bad_alloc& ba)
    {
    CString s;
    s = _T(" std::bad_alloc ");
    AfxMessageBox(s);
    }
    catch (...)
    {
    CString s;
    s = _T("std::bad_alloc, CMemoryException ");
    AfxMessageBox(s);
    };
    if (buf != NULL) delete[]buf;
    if (buf1 != NULL) delete[]buf1;
    };


? MyThrowCatchNew.rar - MFC, ThrowNew.rar - .
MyThrowCatchNew.rar (, : 0)
ThrowNew.rar (, : 0)

https://forum.sources.ru/index.php?showtopic=421011&view=findpost&p=3842827

:  

: [1] []
 

:
: 

: ( )

:

  URL