Making a little library

Hello everybody :smiley:
I’m trying to make myself a little collection of classes that are custom to my needs. I started making a couple like Vector and Point. The problem is I want to be able to use any data type that I want, double, float, int etc. but I want to make one class that can do any of them. the problem would be the getters and setters as I would have to define what type I will return. Also I don’t want to allocate memory for things that I won’t be using in the instance of the class as it’s pretty much useless. So my question is is there a dynamic way to get around this problem without something like the code below ?


class Point{
  int nx,ny;
  double dx,dy;

  Point(int x, int y){
    this.nx = x;
    this.ny = y
  }

  Point(double x, double y){
    this.dx = x;
    this.dy = y
  }
}

Thank you in advance :slight_smile: