[try Beta version]
Not logged in

 
Array of an class??

Jan 18, 2014 at 5:09pm
Why is this incorrect??
1
2
3
4
5
6
7
8
9
10
11
12
13
class rubiks
{
    rubiks Dice[3][3][3];
public:
    rubiks();
    int y;
    int z;
    int upside;
    int front;
    void SetvalueFront(int);
    void cornerPiece(int,int);
    void edgePiece(int);
};


I've made this before, just with an dynamic sized array, so why won't it work with a fixed size array.
Jan 18, 2014 at 5:22pm
In this case, you are saying a rubiks object contains an array of rubiks objects, which each contain an array of rubiks objects, which each contain an array of rubiks objects, ...see the problem?
Jan 18, 2014 at 5:27pm
Actually no.. I thought since my Pixel works, why shouldn't this work??
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
class pixel{
	int red;
	int green;
	int blue;
	string data;
	int height;
	int lenght;
	pixel **billy;
	int max;
	double pythagoras;
	double h;
	double l;
public:
	pixel();
	pixel (int,int,int);
	int getRed();
	int getGreen();
	int getBlue();
};



My idea was to make (as the class reveals) a Rubiks, where i by using 3 coordinates will get an value..
Last edited on Jan 18, 2014 at 5:29pm
Jan 18, 2014 at 5:29pm
In this case, you are saying a pixel object contains a pointer to a pointer to a pixel object; this pointer has a size the compiler can determine, as opposed to your rubiks object where the size of a rubiks object depends on the size of the array inside, which depends on the size of a rubiks object. This circular dependency is the reason for the error.
Jan 18, 2014 at 5:36pm
Well.. that makes sense..
So what youre saying is i just have to change my dice to a rubiks ***dice.
and then allocate three 3 memomry spaces 3 times..
Jan 18, 2014 at 6:01pm
I seem to get an error which doen't not make sense..

The reason why iam unsure about it beeing a error is because Xcode doen't not list it as and error, but just pauses the program..

It' seems to happen here.

The "error message" is "Thread 1 : EXC_BAD_ACESS(code = 2,address =(memorylocation))
Last edited on Jan 18, 2014 at 6:28pm
Topic archived. No new replies allowed.