Writing a single-threaded MongoDB tool with the C++ driver. I always pass the DBClientConnection as a reference argument to any function that requires access to MongoDB. Can I use a global variable instead so that I don't have to pass the argument?
This came up when using Qt's QKeyEvent. This is implemented with this prototype:
void keyPressEvent(QKeyEvent * key_event);
reimplementing:
void QWidget::keyPressEvent ( QKeyEvent * event )
From which function I want to call a MongoDB function but I do not
have access to the DBClientConnection within keyPressEvent. Hence why
I'm considering making DBClientConnection a global.