Anne, the only thought I have is that the declaration of "a" is an automatic variable, and hence may be getting created prior to the applications ability to display any Alert Forms. If you follow Brandon's advice and place this inside a set of curly braces then the creation and destruction will occur only when the corresponding event is fired - or that is what I would expect the compiler to do anyway :-) These things have a habit or varying from compiler to compiler.
Alternatively you could always debug the application and place breakpoints within the constructor/destructor and watch what really happens. HTH Darren. Brandon Wallace <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > I don't know the full answer but noticed one thing that causes confusion. > > Change your code to: > > case menuEvent: > { // Add this open brace > test a; > handled = true; > break; > } // add this close brace > > Local variables defined inside a case statement I believe have scope to the > end of the switch statement if they are not inside curly braces. It is > possible that if your code goes to a case statement below menuEvent() > then the constructor might never get called but the destructor will! > (I am not sure about that part) > I do remember reading that if you are declaring variables in your > case statements, you had better put { } around the case statement > like above to avoid any problems like this. > > Brandon > > Anne Srinivas wrote: > > > > I have a class named test wihich looks like this: > > > > class test > > { > > public: > > file://Constructor for class test > > test() > > { > > FrmAlert(CONSTRUCTOR); // Displays message constructing > > }; > > > > file://Destructor for class test > > ~test() > > { > > FrmAlert(DESTRUCTOR); // Displays message de-constructing > > > > }; > > }; > > > > I am creating an instance of my class test in menu event of > > MainFormHandleEvent like this: > > case menuEvent: > > test a; > > handled = true; > > break; > > > > But the alert DESTRUCTOR is being displayed even if i donot do any > > thing with menu. > > Why should a destructor be called even before my class in instantiated? > > Even if we suppose that class is being instantiated, why should > > destructor be called first? > > It should be constructor which is called first!! > > > > I am using Codewarrior rel 6 with palm os 3.1 > > Where is the problem ? > > > > Thanks in advance > > > > -- > > Anne Srinivas > > Software Engineer > > InfoTech Enterprises Ltd. > > Plot No 11,Infocity, > > Software Units Layout, > > Madhapur,Hyderabad 33 > > > > E-Mail : > > [EMAIL PROTECTED] > > [EMAIL PROTECTED] > > > > Tel (Office) : 3100855 > > Tel (Resi) : 3033761 > > > > -- > > For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/tech/support/forums/ > > -- For information on using the ACCESS Developer Forums, or to unsubscribe, please see http://www.access-company.com/developers/forums/
