March 14th, 2011, 06:37 PM
Out of bounds array problem
I am doing an exercise in which I need to do the following:
Design and implement class myArray
myArray class must solve the array index out of bounds problem and allow the user to begin the array index starting at any integer whether it be positive or negative.
All objects of the class are of the type int.
The program must terminate with an error message if the index is out of bounds during execution.
The book makes me consider the following statements:
myArray<int> myList(2, 13);
myArray<int> yourList(-5, 9);
that list has 5 components ( list-list )
myList has 11 components ( myList - myList )
and yourList has 14 components (yourList[-5] - yourlist ).
It then wants me to write a program to test the class.
I am not sure if it wants me to use list, myList, or yourList stated above in the program either so I was confused about that.
I don't want this done for me, I just need a little help here and there, usually when the ball starts rolling, I can handle it, but this time I started with an error already than I can't figure out, so maybe some prying eyes can help me out! Here's what I have, keep in mind this is just incomplete code just to get something to get it compiling.
using namespace std;
}//End myArray Class
}//End myArray default constructor
}//End myArray constructor
}//End myArray deconstructor
using namespace std;
I keep getting these errors:
Line 2 - In file included from myArray.cpp
Line3:9 - macro names must be identifiers
Line 8 - in Function int main(): 'myArray' undeclared (first use in this function)
(Each undeclared identifier is reported only once for each function it appears in.)
Line 8 - expected ';' before "arrayObject"
[Build Error] [myArray.o] Error 1
Can anyone clarify what mistake I made to get these errors before I start the program?
I think this forum is extremely helpful, so thanks to all of you in advance for helping me in any way possible!
Tags for this Thread
Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!