So, I'm trying to make a very simple class where I have a vector<vector<int> > that I am using as a 2d array, basically. The thing is I keep getting this error code on compilation from XCode and I'm not quite sure what I'm doing wrong.
Face.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#include <iostream>
#include <string>
#include <vector>
usingnamespace std;
class Face {
public:
Face(int iNum, int size);
private:
int num;
vector<vector<int> > colors;
};
Face.cpp
1 2 3 4 5 6 7 8 9 10 11
#include "Face.h"
#include <iostream>
#include <string>
#include <vector>
usingnamespace std;
Face::Face(int iNum, int size) {
num = iNum;
colors = new vector<vector<int> >(size, vector<int>(size, iNum));
}
Ah, well then that would explain the problem...although I am not really sure why you are using a pointer in this case...it probably wouldn't do anything but add extra memory (albeit a very small amount).