[CSI] Lab 8

Mikhail Nesterenko mikhail at cs.kent.edu
Mon Mar 30 22:01:22 EDT 2020


> I'm in CS1B and had a question about Lab 8. Some of the functions are void
> functions, but they ask to print info about the ships so I was wondering if
> there is something I am missing and if you could help me with that.

a void function outputs to the screen. For example,

  void printShip(const Ship&);

will might output

     b6 sunk

on the screen.

>  I am
> also confused with an array. The lab instructions mention an array but
> there isn't one given in the .hpp file, and in some of the functions the
> Ship structure has [] after it making it look like an array so I'm not sure
> if I just don't understand arrays/structures or if there is also something
> else here I'm missing.

These header file contains abbreviated function prototypes.
"Abbreviated" means that the variable names are skipped. However,
everything else about the variable, including whether it is an array
or not, remains. For example,

   void printFleet(const Ship[]);

Prototypes a function that accepts an array of type Ship as a
parameter. An expanded (with variable names) form of the prototype
might be:

   void printFleet(const Ship myFleet[]);

Thanks,
--
Mikhail


More information about the cs13001 mailing list