Jun 9, 2014 at 7:10pm UTC
I think there is a mistake with the code you put on here. Try re-posting with all of your source code and the error message.
Jun 9, 2014 at 7:14pm UTC
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
#ifndef INCLUDE_2DVECTOR
#define INCLUDE_2DVECTOR
#include <vector>
template <typename T>
class 2dvector
{
private :
std::vector<T> data;
unsigned wd, ht;
public :
unsigned width() const { return wd; }
unsigned height() const { return ht; }
const T& operator () (unsigned x, unsigned y) const { return data[(y*wd)+x]; }
T& operator () (unsigned x, unsigned y) { return data[(y*wd)+x]; }
void resize(unsigned w, unsigned h)
{
data.resize(w*h);
wd = w;
ht = h;
}
2dvector() : wd(0), ht(0) { }
2dvector(unsigned x, unsigned y)
: wd(x), ht(y)
, data(x*y, val)
{ }
};
#endif
Its line 7 now, not 8.
Last edited on Jun 9, 2014 at 7:15pm UTC
Jun 9, 2014 at 7:20pm UTC
An identifier must begun with either a letter or underscore. 2dvector
is not a valid name as it begins with a digit.
Jun 9, 2014 at 7:24pm UTC
Oh, OK. I must have glossed over that in the tutorial