2D array in contructor of a class not working

I need to access a 2D array in a constructor of a class but  get a compiling error::
: cannot convert string (*)[6]  to  String**. 
The same code is working with a 1 dimensional array but not with a 2D array.

What do I wrong?????

indef STORE_h
#define STORE_h
#include <Arduino.h>

class Store
{
  public:
    Store(int sizeStore_ , StoreKey store_keys_[], String StoreKeyString_[],String fms_[],
 String stock_[][6]);
  
  private:
    int sizeStore; StoreKey *store_keys; String **stock; String *StoreKeyString; String *fms;
   
};
#endif
#include "STORE.h"

Store::Store( int sizeStore_ , StoreKey store_keys_[], String StoreKeyString_[], String fms_[] , String stock_[][6]) {
  sizeStore = sizeStore_;  store_keys = store_keys_;  StoreKeyString = StoreKeyString_; 
stock = stock_; fms = fms_;
};

For starters you didn't post a complete sketch that illustrates the problem

I removed code becouse it is a large program. But the compile error is appearing when I try to compile this valid class

So write a small sketch that illustrates the problem

1 Like

And for god's sake, fix your code so that each variable definition and each statement is on its own line. This is unreadable:

int sizeStore; StoreKey *store_keys; String **stock; String *StoreKeyString; String *fms;
sizeStore = sizeStore_;  store_keys = store_keys_;  StoreKeyString = StoreKeyString_; 

In addition to the code, please show the error messages

You get a 'can't convert' error because you are trying to store the function argument String stock_[][6] into the private variable String **stock;. If you change the private variable to String (*stock)[6]; it will compile without error.

try stock = &stock_;

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.