//In the Second function: I want "_ax" to change a1, a2, a3, a4...a11 //Is there a way to make 1 function instead of 11?
//Collisions\main.cpp|79|error: '_ax' has not been declared|
class obj {
public:
struct axis
{
bool collide; //0 - Ignore Collisions; 1 - Normal Collision;
double position; //Base of Collisions Calculations
double velocity; //Transotion in 1 tick
double width; //Space taken on axis
double high; //Highest Point on axis
double low; //Lowest Point on axis
};
axis a1;
axis a2;
axis a3;
axis a4;
char* name;
void update();
void setCollide(bool, bool, bool, bool);
void setPos(double, double, double, double);
void setVel(double, double, double, double);
void setWidth(double, double, double, double);
};
//In the Second function: I want "_ax" to change a1, a2, a3, a4...a11 //Is there a way to make 1 function instead of 11?
//Collisions\main.cpp|79|error: '_ax' has not been declared|
An array will help because you'll need only one function to work on that array; you'd simply pass which element of that array you want the function to work on. In any case I'd suggest making large numbers of variables that simply have a different number appended to them an array anyway as it makes programmatical sense since they are all related.
If you're set on trying to use a sort of _ax thing, you could make those variables reference parameters to the function and pass in the particular a1...11 you want as an argument.
1 2 3 4 5 6 7 8 9
void func(int& _ax) {
_ax += 1;
}
int main() {
int a1, a2, a3; // ... assume defined
func(a1); // func() will use _ax to refer to a1
func(a2); //etc.
}