Using 2D servo array in my class I need to use a servo library in my class.
I read this question - Use object of other class within class and it works fine for my LCD application, but now I need to use a 2D servo array in my class. I made one approach, it worked, but I think it is bad programming approach, what is right way to solve my problem?


My main file

#include &lt;SoftwareServo.h&gt; 
SoftwareServo servo[5][5];
Servolib Servoarray;

void setup(){
  blah blah blah

My cpp file

#include "Vending.h"
#include "Arduino.h"
#include &lt;SoftwareServo.h&gt;

Servolib::TurnSevo(){
  for(int row=0;row&lt;5;row++){
    for(int collum=0;collum&lt;5;collum++){
      servo[row][collum].attach(Object[row][collum]);
      servo[row][collum].write(0);
    }
  }
}

my .h file

#ifndef Vending_h
#define Vending_h
#include "Arduino.h"
#include &lt;SoftwareServo.h&gt;

class Servolib:SoftwareServo{
public:
  void TurnServo();

private:
  SoftwareServo servo[5][5];
  int Object[5][5]={
    {42,21,20,19,18},
    {37,41,36,38,35},
    {31,33,30,34,39},
    {67,28,66,29,65},
    {56,63,55,64,54}
  };
};
#endif



So this code worked, but please give me better solution.
You can indeed use pointers, but passing multi-dimensional arrays is a bit of a pain in C(++).

There's a pretty good explanation here.