implement ducktyping in c++