Am having a set of points that are all part of line segments. So I want to create a struct for points, such that it will have a variable pointing to the line the point is a part of.
template<typename T>
struct point{
int x,y;
T* ln;
};
struct line{
point U,L;
};
point a;
a.x = 1;
a.y = 1;
point b;
b.x = 0;
b.y = 0;
line seg1;
seg1.U = a;
seg1.L = b;
a.ln = seg1;
b.ln = seg1;
This dosen't seem to work (The error is 'invalid use of template-name 'point' without an argument list') I dont think this is how we should approach this problem, I do see a few problems with this like when creating point in line struct, T is unknown (I tried adding a constructor but that dosen't seem to work too). Is there a better way to approach this?
Aucun commentaire:
Enregistrer un commentaire