enum { MoveDownRight, MoveUpLeft } state = MoveUpLeft;
while (TRUE) {
switch (state) {
case MoveUpLeft:
move_up_left();
break;
case MoveDownRight:
move_down_right();
break;
}
draw_pixel();
}
cin >> str1 >> str2;
template <class T>
T* create_class(T* object = nullptr)
{
if (obj == nullptr) {
obj = new T();
if (obj == nullptr)
throw Exception("Can't create " + std::string(name_of<T>()) + " object");
}
obj->init();
return obj;
}
...
MyClass* mc = create_class<MyClass>();
delete mc;