What is the best way to do this data structure?
Originally I had;
struct Triangle {
float a, b, c, d, e, f, g, h, i;
}
Now I am trying to implement something like:
struct Triangle {
struct Vertex1 {
float X, Y, Z;
};
struct Vertex2 {
float X, Y, Z;
};
struct Vertex3 {
float X, Y, Z;
};
};
I am kind of new to this type of programming (OBJECT ORIENTED), what do you think would be the best way for setting up the scenario? I chose to use struct because there are no methods in this, just data.
I can think of a few other ways to do this, i.e using classes, or typedefine the vertex structure before putting it into the triangle struct, etc, etc.
Umm, I get errors when I try to access the variables
I am doing:
Code:
TriangleVector[Index]->VertexA->X = XA;
TriangleVector[Index]->VertexA->Y = YA;
TriangleVector[Index]->VertexA->Z = ZA;
And my errors are:
--------------------Configuration: lesson1 - Win32 Debug--------------------
Compiling...
Lesson1.cpp
C:\Documents and Settings\04thibaultc\Desktop\re writing code!\10 - 2 02\Lesson1.cpp(865) : error C2273: 'function-style cast' : illegal as right side of '->' operator
C:\Documents and Settings\04thibaultc\Desktop\re writing code!\10 - 2 02\Lesson1.cpp(865) : error C2227: left of '->X' must point to class/struct/union
C:\Documents and Settings\04thibaultc\Desktop\re writing code!\10 - 2 02\Lesson1.cpp(866) : error C2273: 'function-style cast' : illegal as right side of '->' operator
C:\Documents and Settings\04thibaultc\Desktop\re writing code!\10 - 2 02\Lesson1.cpp(866) : error C2227: left of '->Y' must point to class/struct/union
C:\Documents and Settings\04thibaultc\Desktop\re writing code!\10 - 2 02\Lesson1.cpp(867) : error C2273: 'function-style cast' : illegal as right side of '->' operator
C:\Documents and Settings\04thibaultc\Desktop\re writing code!\10 - 2 02\Lesson1.cpp(867) : error C2227: left of '->Z' must point to class/struct/union
Error executing cl.exe.
lesson1.exe - 6 error(s), 0 warning(s)