Hello!
I'm new to this forum and i'm not english. Hope you can help me either.
I can't understand, why the bool changes, although i'm not setting him to false anywhere:
Code:
#include <iostream>
#include <loki/MultiMethods.h>
struct Base
{
virtual ~Base() {}
};
struct Widget : public Base
{
Widget(int x = 0) : x_(x) {}
int x_;
};
class HatchingExecutor
{
public:
void Fire(Widget& lhs, Widget& rhs)
{
if(lhs.x_ == rhs.x_)
{
bool_ = true;
}
std::cout << "Bool: " << bool_ << " Adresse: " << &bool_ << std::endl;
}
void OnError(Base&, Base&) {}
HatchingExecutor() : bool_(false) { std::cout << "Konstruktor" << std::endl; }
private:
bool bool_;
};
int main()
{
HatchingExecutor exec;
typedef Loki::StaticDispatcher<HatchingExecutor, Base, LOKI_TYPELIST_1(Widget)> Dispatch;
Widget a;
Widget b(1);
Widget c;
Dispatch::Go(a, c, exec);
Dispatch::Go(a, b, exec);
Dispatch::Go(c, b, exec);
}
It shows:
Code:
Konstruktor
Bool: 1 Adresse: 0xbfae3368
Bool: 0 Adresse: 0xbfae3368
Bool: 0 Adresse: 0xbfae3368
I've suggested it would be one everytime, but where is it changed to false?