I was writing a lambda function inside a protected void function of this class
class Tetris: protected TetrisArea<true>
{
public:
Tetris(unsigned rx) : TetrisArea(rx), seq(),hiscore(0),hudtimer(0) {}
virtual ~Tetris() { }
protected:
// These variables should be local to GameLoop(),
// but because of coroutines, they must be stored
// in a persistent wrapper instead. Such persistent
// wrapper is provided by the game object itself.
Piece seq[4];
The lambda function,
auto fx = [&seq]() { seq[0].x=4; seq[0].y=-1;
seq[1].x=Width; seq[1].y=Height-4;
seq[2].x=Width+4; seq[2].y=Height-4; };
So here's the problem. I got these errors:
error: capture of non-variable 'Tetris::seq'
auto fx = [&seq]() { seq[0].x=4; seq[0].y=-1;
error: 'this' was not captured for this lambda function
auto fx = [&seq]() { seq[0].x=4; seq[0].y=-1;
.. and also for subsequent reference of seq[n] in the function.
I tried to type the code directly in the protected void function but although it compiles, it doesn't seem to work normally as the program is from the Youtube channel Bisqwit in his Tetris Dos game.