Trying implementation in c++