leggedrobotics / ros_best_practices

Best practices, conventions, and tricks for ROS
https://rsl.ethz.ch/education-students/lectures/ros.html
BSD 3-Clause "New" or "Revised" License
1.49k stars 413 forks source link

Add example where virtual call is appropriate #31

Open tomlankhorst opened 4 years ago

tomlankhorst commented 4 years ago

Sometimes virtual functions are costly, sometimes not. Show both examples in this repo.

As suggested in #23 by @peci1:

Virtual functions might be costly if the function is called often. Maybe the code could have a non-virtual function OftenCalledFunction and a virtual NotSoOftenCalledFunction. But that decision is on you.