I'm trying to implement a class that contains a valarray and 2 ints that define its size. My hpp file looks something like this:
class Matrix
{
public:
// Constructors
Matrix();
Matrix(int width, int height);
// Mutators
void setWidth(int width); // POST: width of the matrix is set
void setHeight(int height); // POST: height of the matrix is set
//void initVA(double width);
// Accessors
int getWidth(); // POST: Returns the number of columns in the matrix
int getHeight(); // POST: Returns the number of rows in the matrix
// Other Methods
//void printMatrix(const char* lbl, const std::valarray<double>& a);
private:
int width_;
int height_;
std::valarray<double> storage_;
};
However, when I try to initialize the valarray on the constructor like this:
Matrix::Matrix(int width, int height)
{
width_ = width;
height_ = height;
storage_(width*height);
}
I keep getting this error message:
error C2064: term does not evaluate to a function taking 1 arguments
The documentation says that I can declare a valarray in at least 5 different ways, but only the default contructor works. I've looked everywhere but haven't been able to find any useful info. Any help would be appreciated.