Hi,
I was testing something with singletons where I came across a behavior I'm not understanding.
I created a singleton class A. The object had an integer object initialized to 0. The value is expected to increase, on object creation to 1 and further every time I press a button.
Now, since the object is being created only once, I expected the print to be something like:
1
2
3
4
5
and so on, but what I got was:
1
2
2
2
2
I confirmed that the object is being created only once (using debugging), but I just don't understand this behavior. What am I be missing?
Please note that I'm using Qt API, and MainWindow::on_pushButton_clicked() is called every time I press a button while qDebug() works similar to a cout with a suffixed endl in this case.