0

so I am having an issue with defining and declaring my constructor, normally this isnt a problem but this time I the private data is 2 sets of pre filled arrays. And I am not sure of the syntax for doing this as it doesnt seem to follow the normal way for say.

Below is the relevant parts of the code.

class Frequency_Values{
public:
    Frequency_Values(unsigned short LSB_LUT_[], unsigned short MSB_LUT_[]);
    Frequency_Values(const Frequency_Values& F);
    Frequency_Values& operator = (const Frequency_Values& F);
    ~Frequency_Values(){};

private:
 unsigned short MSB_LUT[410] = {1,2,3}; //not the same data, its cut down cause the actual array is large and would make it messy here
unsigned short LSB_LUT[410] = {1,2,3};

//------------------------Constructor definition-----------------------------------------
Frequency_Values::Frequency_Values(unsigned short LSB_LUT_[],unsigned short MSB_LUT_[]):LSB_LUT[](LSB_LUT_[]),MSB_LUT[](MSB_LUT_[]){}
//---------------------------------------------------------------------------------------

The way I have it gives the following errors, Any help with this would be greatly appreciated. Thanks, Dean. enter image description here

Dean
  • 63
  • 5
  • 1
    `LSB_LUT[](LSB_LUT_[])` is not valid syntax for initializing `LSB_LUT`. – Jason Sep 01 '22 at 11:15
  • 2
    Use `std::array` instead of C style arrays. – Eljay Sep 01 '22 at 11:16
  • @JasonLiam what is the correct syntax then, this is what I am confused about. Thanks Dean – Dean Sep 01 '22 at 11:20
  • @Dean Did you read the dupes? In particular, [this answer](https://stackoverflow.com/a/5602047/12002570) might help. There are many more related SO posts where the correct syntax is shown. Better would be to use [`std::array`](https://stackoverflow.com/questions/35030275/in-c-is-it-possible-to-initialize-an-array-directly-from-another) though. – Jason Sep 01 '22 at 11:28

0 Answers0