That’s great! Passing parameters is just giving the function some data to work with.
$latestpost->topic_id is the topic ID. There are probably some functions like
link_to_topic() or similar that you can use to get the title and link. They too will need the topic ID passed as a parameter, so if those are the actual functions it could be
topic_title( $latestpost->topic_id );