Start a new topic

Arduino create list Object

I have this:

NexText sdrow0 = NexText(4, 3, "t0");

NexText sdrow1 = NexText(4, 4, "t1");

NexText sdrow2 = NexText(4, 5, "t2");

NexText sdrow3 = NexText(4, 6, "t3");

NexText sdrow4 = NexText(4, 7, "t4");

NexText sdrow5 = NexText(4, 8, "t5");


I have

void setrow(row, string) {

switch (row) {

  case 0:

  {

    sdrow0.setText(string);

  }

  case 1:

   sdrow1setText(string);


etc etc...


I would write in the various lines without using switch case.

Can i use a list of objects sdrow to use it?

type

list_sdrow(&sdrow0, &sdrow1, &sdrow2, &sdrow3, &sdrow4, &sdrow5)


void setrow(row, string) {

  list_sdrow(row).setText(string);


Help me...

1 Comment

Ok I did ..


NexText *row_list[] =

  {

    &sdrow0,

    &sdrow1,

    &sdrow2,

    &sdrow3,

    &sdrow4,

    &sdrow5,

    NULL

  };


Now

void setrow(row, string) {

  row_list[row]->seText(string);


2 people like this
Login or Signup to post a comment