Click here to Skip to main content
15,907,392 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Generate Bitmap Pin
CPallini3-Feb-08 21:57
mveCPallini3-Feb-08 21:57 
GeneralRe: Generate Bitmap [modified] Pin
azusakt4-Feb-08 14:49
azusakt4-Feb-08 14:49 
Generallife cycle of exception object Pin
George_George3-Feb-08 21:17
George_George3-Feb-08 21:17 
GeneralRe: life cycle of exception object Pin
Maxwell Chen3-Feb-08 21:46
Maxwell Chen3-Feb-08 21:46 
GeneralRe: life cycle of exception object Pin
George_George3-Feb-08 21:54
George_George3-Feb-08 21:54 
GeneralRe: life cycle of exception object Pin
Maxwell Chen3-Feb-08 22:09
Maxwell Chen3-Feb-08 22:09 
GeneralRe: life cycle of exception object Pin
George_George3-Feb-08 22:19
George_George3-Feb-08 22:19 
GeneralRe: life cycle of exception object Pin
Maxwell Chen3-Feb-08 22:30
Maxwell Chen3-Feb-08 22:30 
George_George wrote:
do you think it is still safe to refer to global variable p after function Test returns?


It will crash if changing my previous sample from int type to user defined type (class). As:
class MyClass
{
public:
  int a; // If comment this member out, everything is fine.
         // But if leave it here, you get a runtime error when this app launches.
  ~MyClass() {
    printf("~MyClass \n");
  }
};
MyClass* p = NULL;
void SetN(MyClass& r)
{
  p = &r;
}
void Test()
{
  try {
    MyClass m; // local obj.
    throw m; // throw local obj.
  } // dtor called once.
  catch(MyClass& v) {
    SetN(v);
  } // dtor again.
}
void main()
{  // Runtime error.
  Test(); // You won't have a chance to run this.
  (*p).a;
}


  Maxwell Chen

GeneralRe: life cycle of exception object Pin
George_George3-Feb-08 22:42
George_George3-Feb-08 22:42 
GeneralRe: life cycle of exception object Pin
Maxwell Chen3-Feb-08 22:52
Maxwell Chen3-Feb-08 22:52 
GeneralRe: life cycle of exception object Pin
George_George3-Feb-08 22:56
George_George3-Feb-08 22:56 
GeneralRe: life cycle of exception object Pin
Maxwell Chen3-Feb-08 23:02
Maxwell Chen3-Feb-08 23:02 
GeneralRe: life cycle of exception object Pin
George_George3-Feb-08 23:24
George_George3-Feb-08 23:24 
GeneralRe: life cycle of exception object Pin
Maxwell Chen3-Feb-08 23:35
Maxwell Chen3-Feb-08 23:35 
GeneralRe: life cycle of exception object Pin
George_George3-Feb-08 23:50
George_George3-Feb-08 23:50 
Generalcstring to tchar* conversion Pin
guru moorthy.k3-Feb-08 21:05
guru moorthy.k3-Feb-08 21:05 
GeneralRe: cstring to tchar* conversion Pin
Cedric Moonen3-Feb-08 21:11
Cedric Moonen3-Feb-08 21:11 
GeneralRe: cstring to tchar* conversion [modified] Pin
CPallini3-Feb-08 21:46
mveCPallini3-Feb-08 21:46 
GeneralRe: cstring to tchar* conversion Pin
toxcct4-Feb-08 1:48
toxcct4-Feb-08 1:48 
GeneralRe: cstring to tchar* conversion Pin
CPallini4-Feb-08 2:06
mveCPallini4-Feb-08 2:06 
GeneralRe: cstring to tchar* conversion Pin
toxcct4-Feb-08 2:11
toxcct4-Feb-08 2:11 
GeneralRe: cstring to tchar* conversion Pin
CPallini4-Feb-08 2:16
mveCPallini4-Feb-08 2:16 
Generalsmall issue with combo box. Pin
Chandrasekharan P3-Feb-08 20:58
Chandrasekharan P3-Feb-08 20:58 
GeneralRe: small issue with combo box. Pin
CPallini3-Feb-08 22:02
mveCPallini3-Feb-08 22:02 
GeneralRe: small issue with combo box. Pin
Chandrasekharan P4-Feb-08 0:15
Chandrasekharan P4-Feb-08 0:15 

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.