implementing inheritance function in template