Topic: HELP: Global array of classes defined


Author: charles@sss.cba.ua.edu (Charles Harless)
Date: Fri, 13 Aug 1993 19:19:57 GMT
Raw View
        Hello everyone.  I am new at C++ and have only been programming in
it for about 6 months now.  Still learning alot.  But I will say I like it.
I am using the Borland C++ compiler on MSDOS.

        What I need help on is a small problem.  I have defined a linked
list as a class called LIST.  Now I define an array of linked lists.
                list data_list_array[100];
This is defined globally in my program.  The reason for a global variable is
that it is used by almost all the functions and I had even more problems
passing it back and forth between functions.  :)
        My problem is that my main calls a function which reads in data from
a file and places the data in a particular linked list depending on a
variable.  For example, once it might place the data read into
data_list_array[5].  I have a member function called Insert_End which inserts
a character string into the end of a linked list.  Also after reading in one
line of data I insert "EOP" at the end of the list.  While in this function
I also display the linked list for say data_list_array[5].  Everything
displays fine.  But the problem is when I return back to the main function.
If I try and display data_list_array[5] from the main function it displays
garbage.  I know the data was inserted in the other function but main does
now display the right data.
        Now this is the strange part.  It will display the right number of
elements which should be in the list.  It also displays the "EOP".  But
instead of displaying the real data, such as "AA:10", it displays data like
"k3#%9bl" and other garbage.

        Can anyone give me some help on this.  I need to know as soon as
possible.  My boss has been hounding me for this program for about
a week now.  Thanks for all help.  If you need more information I can post
more.  Just ask and ye shall receive.

        You can respond to me personally (which would be best) or to the
newsgroup.  I don't read the group regularly but I will for the next week.
Send all replies to CHARLES@SSS.CBA.UA.EDU

        Charles Harless
                Systems Support Services
                College of Commerce and Business Administration
                University of Alabama
        CHARLES@SSS.CBA.UA.EDU