Mastery27
Validated user input in C++
#TC1017 #Mastery27
Creation and use of matrixes in C++
Note that also you can use boost.ublas for matrix creation and manipulation and also boost.graph to represent and manipulate graphs in a number of ways, as well as using algorithms on them, etc.
Edit: Anyway, doing a range-check version of a vector for your purposes is not a hard thing:
template
class BoundsMatrix
{
std::vector
unsigned int dimx, dimy_;
public:
BoundsMatrix (unsigned int dimx, unsigned int dimy)
: dimx (dimx), dimy (dimy)
{
inner.resize (dimx*dimy_);
}
T& operator()(unsigned int x, unsigned int y)
{
if (x >= dimx_ || y>= dimy_)
throw 0; // ouch
return inner_[dimx_*y + x];
}
};
Note that you would also need to add the const version of the operators, and/or iterators, and the strange use of exceptions, but you get the idea.
LINK:
http:/
Creation and use of strings in C++
C++ provides following two types of string representations:
The C-style character string.
The string class type introduced with Standard C++.
The C-Style Character String:
The C-style character string originated within the C language and continues to be supported within C++. This string is actually a one-dimensional array of characters which is terminated by a null character ‘