I have attached the files.
I think, there's a problem with listarr.cpp.
I'm not yet good at c++ terminologies, please take time to download and see the files.
I use dev-c.
hmm well im not sure what the program is trying to do. havent looked hard enough at it. but you have a few decleration errors. you put empty in there and thats not not c++ code and if its ment to be a veriable you didnt declare it.
you also have a few sytax errors that shouldnt be there so you messed somthing up in your class stuff. tbh it all looks a bit messy. thats mostly becuase it didnt open tabed out so its all on the baseline :) making it hard to read.
but what i can gather is the main problem is your throws, im not sure what the problem is but there not working in the code. if i understood more about what the program is ment to be doing maybe i can help a little bit better.
Edited by cgcgames: n/a
I hope this helps.
You can implement a list in many ways. Given that all the data items in a list are of the
same type, and that the list structure is linear, an array seems a natural choice. You could
declare the size of the array at compile-time, but your List ADT will be more flexible if you
specify the size of the array at run-time and dynamically allocate the memory required to store
Memory allocation for the array is done by the constructor. The constructor is invoked
whenever a list declaration is encountered during the execution of a program. Once called, the
constructor allocates an array using C++’s new operator. The constructor outlined below, for
example, allocates an array of maxNumber data items and assigns the address of the array to
the pointer dataItems, where dataItems is of type DataType*.
List:: List ( int maxNumber )
. . .
dataItems = new DataType[maxNumber];
Whenever you allocate memory, you must ensure that it is deallocated when it is no
longer needed. The destructor is used to deallocate the memory storing the array. This function
is invoked whenever a list is destroyed—that is, if the function containing the corresponding list
declaration terminates or if the list is explicitly destroyed by the programmer. The fact that the
call to the destructor is made automatically eliminates the possibility of you forgetting to
deallocate the list. The destructor outlined below frees the memory used by the array that you
List:: ~List ()
delete  dataItems;
Another significant implementation issue is what to do when a logbook function such as insert()
or remove() is called with parameters or preconditions that do not meet the stated
requirements. Using the remove() function as an example, it is a logic error to request removal
of an item from an empty list. Although there are many possible ways of dealing with this
situation, the standard C++ method for dealing with bad parameters and other difficult—or
impossible— situations is to throw an exception. Throwing an exception causes the currently
active function to stop execution and return to the calling function. Unless that function or one
of its callers takes special steps to handle the exception, the program will be halted. By using
the C++ try and catch instructions, callers can decide what to do when an exception is thrown.
The try instruction is used when trying something that might cause an exception. The catchinstruction is used to specify what to do if an exception did occur inside the preceding try code
block. Common catch responses to an exception include one or more of the following: 1) print
out a helpful explanation of what went wrong, 2) try to work around the problem, and 3) halt
the program. The empty list problem in the remove() function example can be dealt with by
using the following code snippet at the beginning of the function to enforce the “List is not
if ( size == 0 )
throw logic_error(“Remove: list is empty”);
The C++ exception handling mechanism is quite complicated. Note that for the purpose
of demonstrating the usefulness of exceptions, we have included catch statements in the
test.cpp program to handle any exceptions that are thrown. This is the only test program that
uses them heavily because they tend to clutter the code and make it less readable. We decided
not to sacrifice the readability of the rest of our small test programs by adding complete errorhandling
capabilities. However, these capabilities are mandatory in large complex programs.
Step 1: Implement the operations in the List ADT using an array to store the list data
items. Lists change in size; therefore, you need to store the maximum number of data items the
list can hold (maxSize) and the actual number of data items in the list (size), along with the list
data items themselves (dataItems). You also need to keep track of the array index (cursor).
Base your implementation on the following declarations from the file listarr.h.
Step 2: Save your implementation of the List ADT in the file listarr.cpp. Be sure to
document your code.
The following program (test.cpp) uses the array implementation of the operations in the List ADT to read in a list of integer samples and compute their sum.
Nice job of spouting off your assignment, but you really haven't given us anything about your expectations for your program or any information about what is/isn't working the way you expected. Did you even bother to read it yourself? Your code is full of throws, but there aren't any try or catch blocks as are required by the exception system, and mentioned in your wall of text. Also, according to your wall, there should be several catch blocks in your test.cpp file, I don't even see 1.
You actually have to try to do your own homework, and throw your arms out when you trip while trying, before we'll catch you.
Edited by Fbody: n/a
This is actually not an assignment it's a tutorial.
I'm new to ADT's and creating classes and exceptions?? that's why I posted the "wall of text". I was just looking for someone here who could help me determine the problem and suggest some reference sites I could visit to help me fix the problem. Anyway, your comment helps. Thanks a lot.
only just got up and was able to read through all this and Fbody is right. he pretty much said my first conclution. however i hardly ever use throws in my code. i genrally work around them :).
however you have used them with out any trys or catches which is expected. it even tells you in the error log. you have like 15 errors saying the throw doesnt work and like Fbody said use try and catch statments. jsut type in goodle try and catch statments in C++. that should get you somthing helpful if you havent already done so.
anyway good luck with it. sorry i couldnt be of more help
Edited by cgcgames: n/a
A person starts out as the "Curator" and stands at the end of a field. Everyone else playing stands at the far end (distance depends upon playing area selected). The ...
I am currently working on a program to track my mile for my monthly expense report for work. Everything is working great, however, I can not for the life of ...
I am trying to understand the SynchronizedMap and I ran the below code. I get the below Output with an exception. According to my understanding the exception is caused when ...