- #1
anonim
- 40
- 2
- Homework Statement
- -
- Relevant Equations
- -
I am now learning C ++ and trying to learn class and vector. I'm trying to write code, but I got an error.
this is my class and enum class:
I'm stuck in assigning values to members in the private class and then I wrote like this but I am not sure this is right.
And :
when I tried compile, I get an error: temp1 is private within this context
this is my class and enum class:
Code:
enum class state: char{ empty='.', filled_with_x='x', filled_with_o='o'};
Code:
class class1{
private:
class class2{
class2();
int x;
int y;
char z;
};
private:
int size;
vector< vector<class2>>vec;
public:
class1();
class1(int size);
void fill_vector();
};
Code:
class1::class2::class2() : x(-1), y(-1),z(static_cast<char>(state::empty)){};
And :
Code:
void class1::fill_vector(){
class2 temp1;
int i,j;
vector<class2>temp;
for(i=0; size>i;i++){
for(j=0; size>j; j++){
temp.push_back(temp1);
}
vec.push_back(temp);
}
}
when I tried compile, I get an error: temp1 is private within this context