Re: Need access to private data


[ Follow Ups ] [ Post Followup ] [ CS2604 Discussion WWWBoard ] [ FAQ ]

Posted by Sleepless Snowman on July 22, 1999 at 16:51:38:

In Reply to: Need access to private data posted by Kancheng Cao on July 22, 1999 at 15:44:08:

: I have problem getting the "Head" pointer from the "WindowList" class. the project specification said that I cannot modify the file, How can I get the pointer then?

: The reason I need the "Head" pointer is that I cannot pass a member function of a class to the "Traverse" function.

: Can you give me permission to change the "private" keyword in the "WindowList" class to "protected"?

: Thanks!

: kancheng Cao


When you call the Traverse method on the object WindowList, you are inside the object. Once inside, you can do whatever you want with it. If you want to modify Head, great! But because it is private, you wouldn't be able to do stuff like

wl->Head=NULL;

That is because you wouldn't have to. If you need to modify the Head externally, then I think you maybe making it too hard on yourself...

but then again, I m not really sure what I am saying anyways...and of course it is just an opinion.

By the way, why are you trying to pass a member function into Traverse()? If I think you are doing what I think you are doing, you don't have to. Because that is what ShowWindow does. You already passed in a pointer to the function ShowWindow into Traverse(). This makes the ShowWindow function available to the WindowList object. Now you are inside the object, you can use invoke the ShowWindow function by simply invoking it. However, way how the interface is written, the pointer to ShowWindow is copied into a pointer named Visit. So if you want to use it, just call

Visit(Head);

which he explained in class.

Hope that helps...


Follow Ups:



Post a Followup

Name:
E-Mail:

Subject:

Comments:

Optional Link URL:
Link Title:
Optional Image URL:


[ Follow Ups ] [ Post Followup ] [ CS2604 Discussion WWWBoard ] [ FAQ ]