I am trying to write a program that will initialize a new "Square" object with private const data member "side". I have written it properly to do so, but I need to write in a check to make sure "const char* token" is not a NULL pointer, and if it is, to initialize"side" to 0 instead. Here's what I have so far:
Thanks a bunch! That worked just as I needed it to! The reason its in the second index is because the first index identifies the shape (SQUARE, RECTANGLE, etc) and subsequent tokens are sides, length, radius depending on the shape.
The reason its like that is because the sides and such are parsed from a text file. Also I could use strings, but that's not what the assignment criteria called for.
Well, I would still suggest you leave the converting from C-string to floating point outside of the constructor. It just makes your class more sensible that way. Plus, you can centralize all the conversions somewhere else.