Thread View: csu.cs.200
3 messages
3 total messages
Started by christopher brockmeier
Fri, 09 Oct 1998 00:00
Program 4 initialize
Author: christopher brockmeier
Date: Fri, 09 Oct 1998 00:00
Date: Fri, 09 Oct 1998 00:00
10 lines
1083 bytes
1083 bytes
Help! I don't understand how we are supposed to initilize the lists when Main4.C simply calls list_name.LIST_AddAtEnd(data);If you cant set "used" to zero the list doesn't get initial- ized, but how can you tell the status of the list? If it is AddAtEnd of nothing that's what I get: nothing. So I've trid to check with an if statement if data[0] (my array) has a null value for name, if it does I initialize it. It doesn't compile this way. Another thing is that LIST_Create and LIST_ Destroy are getting flagged for not returning values... I think my code is exactly as it is in the notes and book for this. If anyone can help please reply! kempf@cs....
Re: Program 4 initialize
Author: Chris Carlson
Date: Fri, 09 Oct 1998 00:00
Date: Fri, 09 Oct 1998 00:00
20 lines
1583 bytes
1583 bytes
LIST_Create and LIST_Destroy need to become you class constuctor and destructor, respectively. This way, when the class is created the list will be created, and when the class loses focus the list is destroyed. This was in the assign#4 handout and should fix your problem. Chris Carslon christopher brockmeier wrote: > Help! I don't understand how we are supposed to initilize the > lists when Main4.C simply calls list_name.LIST_AddAtEnd(data);If you cant set "used" to zero the list doesn't get initial- > ized, but how can you tell the status of the list? If it is > AddAtEnd of nothing that's what I get: nothing. So I've trid > to check with an if statement if data[0] (my array) has a null > value for name, if it does I initialize it. It doesn't > compile this way. Another thing is that LIST_Create and LIST_ > Destroy are getting flagged for not returning values... I > think my code is exactly as it is in the notes and book for > this. If anyone can help please reply! kempf@cs....
Re: Program 4 initialize
Author: cassic
Date: Tue, 13 Oct 1998 00:00
Date: Tue, 13 Oct 1998 00:00
32 lines
2325 bytes
2325 bytes
I'm not positive I understand your question perfectly, but I think the issue is how to initialize the lists, when the first call to a list is "AddAtEnd" as opposed to something like "INITList." (Let me know if that's not what you meant). Remember that classes have constructors instead of initialization functions (well, you could still have an init function, but here we don't need one). Whenever you declare an object of that class, the constructor for the class is called - i.e. when you declare a list the constructor (or "initializer") gets called automatically. Since you have to have declared a list variable before you can call AddAtEnd, this initialization must have already taken place. Hope that helps. Chris In article <6vm3nr$bh3c@yuma.ACNS.ColoState.EDU>, brockmei@glinka.cs.colostate.edu ( christopher brockmeier) wrote: > Help! I don't understand how we are supposed to initilize the > lists when Main4.C simply calls list_name.LIST_AddAtEnd(data);If you cant set "used" to zero the list doesn't get initial- > ized, but how can you tell the status of the list? If it is > AddAtEnd of nothing that's what I get: nothing. So I've trid > to check with an if statement if data[0] (my array) has a null > value for name, if it does I initialize it. It doesn't > compile this way. Another thing is that LIST_Create and LIST_ > Destroy are getting flagged for not returning values... I > think my code is exactly as it is in the notes and book for > this. If anyone can help please reply! kempf@cs.... > -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads