Problem in Accessing CArray object
-
Hi All, I am using CArray object to store the strings in array. I used this object in one class where i add strings in to CArray object. I want to access this object in other class. But when i access it in other class it gives me garbage values. So how can i access it in another class. I created CArray object on the stack. Is there any need to create it on Heap. Thanks in Advance Atul
-
Hi All, I am using CArray object to store the strings in array. I used this object in one class where i add strings in to CArray object. I want to access this object in other class. But when i access it in other class it gives me garbage values. So how can i access it in another class. I created CArray object on the stack. Is there any need to create it on Heap. Thanks in Advance Atul
-
I am accesssing CArray object in other class as follows CWebsiteCreatorWizard *pPtr = (CWebsiteCreatorWizard *)GetParent(); if(NULL != pPtr) nTotalWebPageCount = pPtr->m_WebSitePagesAry.GetSize(); Where CWebsiteCreatorWizard is wizardseet class in which i declare CArray m_WebSitePagesAry is array of strings could u guess why I get here Garbage value in nTotalWebPageCount. Regards A23
-
I am accesssing CArray object in other class as follows CWebsiteCreatorWizard *pPtr = (CWebsiteCreatorWizard *)GetParent(); if(NULL != pPtr) nTotalWebPageCount = pPtr->m_WebSitePagesAry.GetSize(); Where CWebsiteCreatorWizard is wizardseet class in which i declare CArray m_WebSitePagesAry is array of strings could u guess why I get here Garbage value in nTotalWebPageCount. Regards A23
Atul23 wrote:
CWebsiteCreatorWizard *pPtr = (CWebsiteCreatorWizard *)GetParent();
first make sure that, the above line fetches you the correct pointer of your required class. to do that, first, you define a simple integer variable, say int temp=47; in CWebsiteCreatorWizard class. then try to access it and see its value. if its value is 47, then, we can proceed to find the next step to localise the problem.
-
Atul23 wrote:
CWebsiteCreatorWizard *pPtr = (CWebsiteCreatorWizard *)GetParent();
first make sure that, the above line fetches you the correct pointer of your required class. to do that, first, you define a simple integer variable, say int temp=47; in CWebsiteCreatorWizard class. then try to access it and see its value. if its value is 47, then, we can proceed to find the next step to localise the problem.
-
Hi Chandu, I can not access value of temp in other class by using pointer. so could u give me next steps please. Thanks in Advance A23
-
Hi Chandu, I can not access value of temp in other class by using pointer. so could u give me next steps please. Thanks in Advance A23
in continuation with Chandu(good reply) better look for singleton design!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
Never mind - my own stupidity is the source of every "problem" - Mixturecheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You
-
in continuation with Chandu(good reply) better look for singleton design!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
Never mind - my own stupidity is the source of every "problem" - Mixturecheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You
-
ThatsAlok wrote:
better look for singleton design!
can you explain? thank you. ------------------------------------------
Suggestion to the members: prefix your main thread subject with [SOLVED] if it is solved. chandu.
chandu004 wrote:
can you explain?
please refer this :- Singleton Pattern[^] instead of making global variable.. it is better to use singleton class.!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
Never mind - my own stupidity is the source of every "problem" - Mixturecheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You
-
I am accesssing CArray object in other class as follows CWebsiteCreatorWizard *pPtr = (CWebsiteCreatorWizard *)GetParent(); if(NULL != pPtr) nTotalWebPageCount = pPtr->m_WebSitePagesAry.GetSize(); Where CWebsiteCreatorWizard is wizardseet class in which i declare CArray m_WebSitePagesAry is array of strings could u guess why I get here Garbage value in nTotalWebPageCount. Regards A23
Is
GetParent()
returning a valid (i.e., the actual parent) pointer? Note that just because the value is non-NULL
does not mean it is valid. Ism_WebSitePagesAry
non-empty? Even if it wasn't,nTotalWebPageCount
would be 0 (assuming that the answer to my first question is "yes").
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne