I've learned a bit about classes and vectors recently. so I've tried putting 'em together. Here's the error-full code I came up with:
#include "DarkGDK.h"
#include <vector>
using namespace std;
struct point
{
float x;
float y;
int a;
};
struct tri
{
point a;
point b;
point c;
};
class polygon
{
vector<tri> tris();
vector<point> verts();
vector<int> vert();
public:
polygon(int verts);
~polygon(){};
void set_vert(int vertnum, point a);
void set_tri(int trinum, point t1, point t2, point t3);
int add_vert(void);
int add_tri(void);
void clear_verts(void);
void clear_tris(void);
void lgvert_create(void);
void lgvert_set(int index, int a);
void lgvert_clear(void);
//float get_area();
}
polygon::polygon(int verts)
{
verts.resize(verts);
}
void polygon::set_vert(int vertnum, point a)
{
verts.at(vertnum)=a;
}
void polygon::set_tri(int trinum, point t1, point t2, point t3)
{
tri triangle;
triangle.a=t1;
triangle.b=t2;
triangle.c=t3;
tris.at(trinum)=triangle;
}
int polygon::add_vert(void)
{
verts.push_back(0);
return verts.size();
}
int polygon::add_tri(void)
{
tris.push_back(0);
return tris.size();
}
void polygon::clear_verts(void)
{
verts.clear();
}
void polygon::clear_tris(void)
{
tris.clear();
}
void polygon::lgvert_create(void)
{
vert.resize(verts.size());
}
void polygon::lgvert_set(int index,int a)
{
vert.at(index)=a;
}
void polygon::lgvert_clear(void)
{
vert.clear();
}
void DarkGDK ( void )
{
polygon ohai(30);
ohai.add_vert();
ohai.clear_verts
}
I'm sure that this is all because of me improperly declaring the vector arrays, but I'm not sure how to correct this. Would I have to declare the vector arrays in the constructor? I'm pretty lost here, and I haven't been able to find much searching the web. Any help?