Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi I have a class Class MM{ p

Status
Not open for further replies.

sskumar

Programmer
Joined
Sep 12, 2002
Messages
36
Location
US
Hi
I have a class
Class MM{
public:
SetInterfacePtr( IsomeInterfacePointer *y)
{
xx = y;// crashing place
};
private:
IADFsomeInterfacePointer *xx;
};

When i have an object variable of type class MM
and call its SetInterfacePtr function it is crashing...

I checked for the content it is not NULL.
What might be the problem?
Can we assign an Interface pointer to another?

S.Senthil Kumar
 
Senthil:

I guess your problem could be the following:

When you define an object, some space of the memory will keep reserved to that object in particular, aparently you define your xx pointer as a private member of your MM class so it will be created in your object's reserved space of memory, any attemp to make xx to point out of this reserved memory space will produce an unpredictable behavior, so please check if your y pointer is also a member of your MM object,

Hope this helps ,

Ricardo
 
Thanks
But The problem is i get (IADFsomeInterfacePointer *)y from some other funtion which i need to assign to Class xx member

S.Senthil kumar
 
Well, without the code I dont know what the problem would be but I have a few guesses.

1. The object passing the pointer either goes out of scope or is deleted. When you try to access it, it crashes because the memory has been cleared.

2. IADFsomeInterfacePointer does not inherit from IsomeInterfacePointer and therefore can not be properly assigned. Do you derived from CObject, if so, you could impliment IMPLIMENT AND DECLARE DYNAMIC and from there perform an "IsKindOf" on it to determine if you are indeed getting the right kind of object.

3. If indeed the assignment is crashing, that seems a bit weird to me. I would say check the line following the function call. The call is inline and written into the code. It MAY be bringing you to the line prior to the problem. Look at the call stack and see if the next line of code calls something that does something with that pointer.

I hope these point you in the right direction. Repost if this was no help and I will see what else i can come up with.

Matt

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top