Sams Teach Yourself C++ in 21 Days

(singke) #1
Answers 847

D


Rectangleparts, this will be fine. If you do need the Rectangleparts, you’ll need
to change SomeFunctionto take a pointer or a reference to a Shape.


  1. You can’t declare a copy constructor to be virtual.


Day 13


Quiz

1.SomeArray[0],SomeArray[24]


  1. Write a set of subscripts for each dimension. For example,SomeArray[2][3][2]is
    a three-dimensional array. The first dimension has two elements, the second has
    three, and the third has two.
    3.SomeArray[2][3][2] = { { {1,2},{3,4},{5,6} } , { {7,8},{9,10},{11,12}
    ➥} };

  2. 10520=1,000

  3. Both arrays and linked lists are containers for storing information; however, linked
    lists are designed to link together as needed.

  4. This string contains 16 characters—the fifteen you see and the null character that
    ends the string.

  5. The null character.


Exercises


  1. The following is one possible solution. Your array might have a different name, but
    should be followed by [3][3]in order to hold a 3 by 3 board.
    int GameBoard[3][3];
    2.int GameBoard[3][3] = { {0,0,0},{0,0,0},{0,0,0} }

  2. The following is one possible solution. This uses the strcpy()and strlen()
    functions.
    #include
    #include <string.h>
    using namespace std;


int main()
{
char firstname[] = “Alfred”;
char middlename[] = “E”;
char lastname[] = “Numan”;
char fullname[80];
int offset = 0;

32 0672327112_app_d.qxd 11/19/04 12:30 PM Page 847

Free download pdf