Click here to Skip to main content
15,897,187 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: throw exception after allocating some memory Pin
followait23-Dec-10 21:38
followait23-Dec-10 21:38 
QuestionRe: throw exception after allocating some memory Pin
CPallini23-Dec-10 22:00
mveCPallini23-Dec-10 22:00 
AnswerRe: throw exception after allocating some memory Pin
bleedingfingers23-Dec-10 21:40
bleedingfingers23-Dec-10 21:40 
AnswerRe: throw exception after allocating some memory Pin
jk chan23-Dec-10 21:46
jk chan23-Dec-10 21:46 
GeneralRe: throw exception after allocating some memory Pin
followait24-Dec-10 5:07
followait24-Dec-10 5:07 
GeneralRe: throw exception after allocating some memory Pin
Eugen Podsypalnikov24-Dec-10 8:48
Eugen Podsypalnikov24-Dec-10 8:48 
GeneralRe: throw exception after allocating some memory Pin
followait24-Dec-10 20:39
followait24-Dec-10 20:39 
GeneralRe: throw exception after allocating some memory Pin
Eugen Podsypalnikov24-Dec-10 23:26
Eugen Podsypalnikov24-Dec-10 23:26 
All of the variables local defined in a function,
will be constructed on the stack at the beginning of the function
and then destructed - at the end of the function (even there was a throwing) Smile | :)

So you could provide a class for a function service, for example:

class CDBStatement;

class CDBStatementService // a pseudo-function-service :)
{
  bool m_bOwner;
  CDBStatement* m_pcStatement;

public:
  CDBStatementService(CDBStatement* pcStatement, bool bOwner)
    : m_pcStatement(pcStatement), m_bOwner(bOwner) {};

  ~CDBStatementService() {
    if (m_pcStatement) {
      m_pcStatement->Close();
      if (m_bOwner) {
        delete m_pcStatement;
      }
    }
  }
};

void TestThrowing()
{
  CDBStatementService cDBStatementService(new CDBStatement(), true);

  // here could be a throwing... :)
  //..

} // the destructor of the service will be called, even there was a throwing 

They sought it with thimbles, they sought it with care;
They pursued it with forks and hope;
They threatened its life with a railway-share;
They charmed it with smiles and soap. Smile | :)

GeneralRe: throw exception after allocating some memory Pin
jk chan26-Dec-10 21:30
jk chan26-Dec-10 21:30 
AnswerRe: throw exception after allocating some memory Pin
Aescleal24-Dec-10 3:59
Aescleal24-Dec-10 3:59 
GeneralRe: throw exception after allocating some memory Pin
followait24-Dec-10 5:11
followait24-Dec-10 5:11 
QuestionHow to restrict drag and drop from explorer to my application? Pin
krishnakumartm23-Dec-10 3:15
krishnakumartm23-Dec-10 3:15 
AnswerRe: How to restrict drag and drop from explorer to my application? Pin
David Crow23-Dec-10 15:50
David Crow23-Dec-10 15:50 
QuestionHow can i use a exported class from DLL with .EXP and .DLL File Pin
bankey101023-Dec-10 2:14
bankey101023-Dec-10 2:14 
AnswerRe: How can i use a exported class from DLL with .EXP and .DLL File Pin
T210223-Dec-10 12:48
T210223-Dec-10 12:48 
QuestionData Structure library for windows Pin
pandit8423-Dec-10 2:08
pandit8423-Dec-10 2:08 
AnswerRe: Data Structure library for windows Pin
Maximilien23-Dec-10 4:12
Maximilien23-Dec-10 4:12 
QuestionPre used resource ids by visual studio Pin
Harsh Shankar22-Dec-10 23:45
Harsh Shankar22-Dec-10 23:45 
QuestionHow can i load a win32 DLL which expoting Classes? Pin
bankey101022-Dec-10 20:28
bankey101022-Dec-10 20:28 
AnswerRe: How can i load a win32 DLL which expoting Classes? Pin
Cedric Moonen22-Dec-10 21:19
Cedric Moonen22-Dec-10 21:19 
AnswerRe: How can i load a win32 DLL which expoting Classes? Pin
ThatsAlok22-Dec-10 22:37
ThatsAlok22-Dec-10 22:37 
AnswerRe: How can i load a win32 DLL which expoting Classes? Pin
bleedingfingers22-Dec-10 23:27
bleedingfingers22-Dec-10 23:27 
GeneralRe: How can i load a win32 DLL which expoting Classes? Pin
bankey101023-Dec-10 2:48
bankey101023-Dec-10 2:48 
GeneralRe: How can i load a win32 DLL which expoting Classes? Pin
bleedingfingers23-Dec-10 22:08
bleedingfingers23-Dec-10 22:08 
AnswerRe: How can i load a win32 DLL which expoting Classes? Pin
Ralf.Bue23-Dec-10 8:19
Ralf.Bue23-Dec-10 8:19 

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.