Initiate member variable??
| Tue, 2007-10-09 14:32 | |
|
|
I define a TInt variable in .h file,and initiate it in default Construct function,the code as below: TInt m_nWidth;in cpp,initiate the variable m_nWidth CImageDecode :: CImageDecode (CAppController& aController)and then in the GetImageWidth() function: TInt CImageDecode:: GetImageWidth()But when I define variable like this: TInt CImageDecode:: GetImageWidth()it Works very well. I cann't understand why. Can somebody get me out? |






Forum posts: 982
Are you sure in your first case is TInt and not TInt* ?
Also can you let us know what error do you het there? (when app crashes)
pirosl
Forum posts: 7
pirosl,Thanks for your quick reply.
Yes,I am sure it is TInt not TInt*.
and I don't know how to catch the error code when it crashes.
Because I run the app on the phone.
And can you guide me how to catch the error code?
Forum posts: 8
Are you sure by the time you call GetImageWidth(), your CImageDecode object is not deleted (and maybe set to NULL)?
Forum posts: 982
Can you share the h and cpp file?
pirosl
Forum posts: 159
If its a member variable why doesn't it begin with i like iController does?
Lets see how you create its parent object before you use it. I hope you're not doing something daft like
CImageDecode* decode;
decode->GetImageWidth();
Forum posts: 672
Set a breakpoint in the method and check out the value of this pointer. Is it valid?