the matrix is supposed to be 2d, however im not sure how to declare it. u can basically ignore the code i have written in CMatrix::Fill. because i have absolutely no idea what to do
it depends on how CMatrix is declared, but still I do not understand what Fill is supposed to do.
Let me assume the character map is a c-style array, the loop should look like
// File: cmatrix.h
// ============================================================================
// This header file contains the declaration for the CMatrix class. The class
// is used by the CScreen class to help fill the screen display with characters
// at random localtions.
// ============================================================================
#ifndef CMATRIX_H
#define CMATRIX_H
#include <iostream>
#include <fstream>
usingnamespace std;
// class declaration
class CMatrix
{
public:
// constructor
CMatrix(int numRows, int numCols);
// member functions
void Fill(char dispChar, int msecs);
private:
int m_numRows;
int m_numCols;
};
#endif // CMATRIX_H
and how can I declare a 2d with an unknown number of elements? The fill function is basically supposed to fill the screen with asterisks at random locations. and i have no idea how will they fill randomly
cmatrix.h -- This header file contains the declaration for the CMatrix class. The purpose of this class is to fill the screen with a character at random locations. If you look at the class declaration, you'll see that it only has two data members: one to store the total number of rows, and another to store the total number of columns. These data members are initialized by the class constructor, which receives those values in the parameter list.
Once the CMatrix object has been initialized, it's ready to have its CMatrix::Fill member function called. This function takes as input a character to draw, and a sleep interval to control the speed with which they're drawn. A loop is entered to draw the character to random locations on the screen, until all available locations have been used and the screen is completely filled. (Hmm... how will it keep track of available screen locations? How will it know when the screen has been completely filled?)