How can I change the signature of distanceTo(..)
to make the compiler warn or error on a call with std::size_t
as parameter?
class Point {
private:
float value;
public:
Point(float value) : value(value){};
float distanceTo(const Point &point) { return point.value - value; }
};
int main() {
std::size_t index = 1;
Point start(1);
Point end(4);
float dist = start.distanceTo(index); // compiles, but should not!
std::cout << dist;
return 0;
}
Aucun commentaire:
Enregistrer un commentaire