@dhayden - we have a warpspace parameter to Square's constructor, so the geometry might be non-Euclidean? :)
@OP - I'm kind of unclear where you're stuck. I do have a number of comments though.
ShapeTwoD.h - Your include guard is incomplete. You define a symbol, but fail to exclude the contents of the head if the symbol is already defined. I don't see this as a problem currently, as you don't appear to include the header multiple times. Just a comment that you need to research include guards and use them correctly.
http://www.cplusplus.com/forum/general/71787/
ShapeTwoD.h line 8: Not a good idea to put
using namespace std
inside an include file.
main.cpp lines 5-13: It's best practice to avoid the use of globals. These variables should be locals within main.
4th snippet: I see an include of points.h, but I don't see that you posted it, although there is a struct in main.cpp named Point. Not sure if these are the same.
5th snippet:
Line 1: I don't see size declared anywhere. I'm going to assume it is properly declared and has a const value. If it's not a const value, you can't declare an array with a non-const value.
line 2: This is an out of bounds assignment. Lets assume size is 10. elements of arrayofShape are [0]-[9]. You're trying to store into [10].
line 3: Why are you incrementing size? This will cause the subsequent for loop to go out of bounds. (size now equals 11). You may have been assuming size was 0 here, but that would make your allocate illegal.
Have you learned about std::vector yet? If the number of points in the array is going to change, this would best be done with a vector<Shape>. If not, then what I think you want is something like the following:
1 2 3 4 5 6 7 8 9
|
Shape *arrayofShape;
int size = 10; // Number of shapes to be stored
int numShapes = 0; // Number of shapes currently stored
// Do once
arrayofShape = new Shape * [size]; // Allocate array of pointers to shapes
// Do for each share to be stored
arrayofShape[numShapes++] = &someshape; // Assume someshape exists
|
Note that size and numShapes are independent variables.
Don't forget to deallocate arrayofShape when you're done with it, or you will have a memory leak.