Ok, I have changed my code, as well as my state of mind. Thanks for that article as I think it helped me understand a few things a little better.
However I am still ignorant to iterators and their functionality. I know a vector is simply a object that points to the direction of memory inside a vector, but it's very fuzzy and gray. I tried, and failed miserably at making a iterator for a vector in a vector. Also My class is still very nonfunctional.
I have revised the code much, yet it is still very bad.
Code:
using namespace std;
class cube
{
public:
// set up parameters of the cube, such as it's height, width, and and vertices.
// we are also going to overload the constructor so giving height and width is optional
// if not giving, it will be calculated when called
cube::cube(vector<vector<float>> vert);
cube::cube(vector<vector<float>> vert, float height, float width);
// get the vertices of a cube
vector<vector<float>> getVertices(); // returns array
// shift the cube x amount of units in x, y, and z dirctions
void shiftCube(vector<float>cords);
private:
struct cubeIndex
{
// clockwise on top, then clockwise on bottom
vector<vector<float>> vertices;
// parameters of the cube
float width;
float height;
float area;
} cubeSpecs;
vector<vector<float>>::iterator rowIt;
vector<vector<float>>::iterator rowEnd;
vector<vector<float>>::iterator colIt;
vector<vector<float>>::iterator colEnd;
vector<float>::iterator cordIt;
}
cube::cube(vector<vector<float>> vert)
{
cubeSpecs.vertices = vert;
rowIt = cubeSpecs.vertices.begin();
rowEnd = cubepecs.vertices.end();
}
cube::cube(vector<vector<float>> vert, float height, float width)
{
cubeSpecs.vertices = vert;
cubeSpecs.height = height;
cubeSpecs.width = width;
rowIt = cubeSpecs.vertices.begin();
rowEnd = cubepecs.vertices.end();
}
void cube::shiftCube(vector<float> cords)
{
// here is where we iterate the vector of vectors
for( ; rowIt != rowEnd; rowIt++)
{
colIt = rowIt->begin();
colEnd = rowIt->end();
for( ;colIt != colEnd; colIt++)
{
// iterator for vector of cords coming in
for(cordIt = cords.begin(); cordIt != cords.end(); cordIt++)
{
*colIt += *cordIt;
}
}
}
}
}
vector<vector<float>> cube::getVertices()
{
return cubeSpecs.vertices;
}
I want to try and get an understanding of the material, so any good tutorials that will explain anything to me, that you think I could use, would be of great help. Particularly in the subjects of vector + iterators, classes, arrays(particularly receiving them and returning them in a function).
Thanks you for your time and effort,
Joe