Struct and Class Templates

You will learn about structs and class templates in this lesson.

The Point struct may be seen as having a limitation. Because its two members are defined specifically as int, it cannot represent fractional coordinate values. This limitation can be removed if the Point struct is defined as a template.

Let’s first add a member function that returns the distance to another Point object:

Get hands-on with 1000+ tech skills courses.