The right usage of classes and struct within them

I'm having trouble with a class "Set" I try to use.
The Idea is to be able to access its properties from a public function in Set.

here is a minimal code sample:

#include <FastLED.h>
#define LEDTYPE WS2812B 
#define PL 9                           // LED pin
#define STRIP 134                  //num LED in strip
#define GROUP_NUM 9

CRGB LED[STRIP]; 

void setup() {
  delay(200); 
  FastLED.addLeds<LEDTYPE, PL, GRB>(LED, STRIP);                                                                     
}


class Set {
  public:
    Set() {} //constructor
    struct group {
      byte red, green, blue;
    };
    struct set {
      int setDelay;
      group group[GROUP_NUM];
    };
    //    void sets();
    void GroupPlacement(set);
  private:
    //   void groupPlacement(set);

};

Set set1;

set1.set.setDelay = 50;
set1.set.group[0] = (.100, .0, .0);
set1.group[1] = (0, 100, 0);

void Set::GroupPlacement(set thisset) {
    thisset.group[0] = (1,2,3)
}

void loop() {
set1.GroupPlacement(set1)
}
  1. I'm getting an error that invalid use of struct Set::set. But I initialised set1 of Type Set, what is the mistake here?

  2. what is the correct way to access group[]? is it like I try with group[0] or group[1] (notice the dot)
    error is: "error: no match for 'operator=' (operand types are 'Set::group' and 'int')"

Thanks a bunch!

I get an error reporting

'GROUP_NUM' was not declared in this scope

right, sorry I must have erased it while taking everything unnecessary. say Its 10. Its not relevant for the questions.

Edited the question.

"group" and "set" are type names, not variable names. Further information.

EDIT: You usually never declare types within a class unless they are private to the class.

But isn't it more orderly to have a bundle of information in the form of struct, so i can pass it, for example in an array as easy as possible?

What would I do instead to organize passing variables to functions in arrays?

Multiple things wrong here:

  • As already pointed out, you only declare struct types group and set. You never define (instantiate) any class members of these types.

  • You instantiate a single object of type Set called set1. Yet, you try to use this variable as an array.

  • You can’t assign values to struct members like you’re trying to do with:

set1.set.group[0] = (.100, .0, .0);
set1.group[1] = (0, 100, 0);
  • The parameter type you’re trying to pass in the definition of GroupPlacement() doesn’t exist. Perhaps you meant “Set thisset”.

  • Regardless of the above, you’re passing by value which means ‘thisset’ is a local variable to GroupPlacement(). Any changes you make to it will have no effect to the argument when the function is called. You need to pass by pointer or reference.

  • Your naming convention is very confusing.

You can use a struct in your class, but read reply #3 again. You defined a struct in your class, but you didn't declare an instance of that struct.

wildbill:
You can use a struct in your class, but read reply #3 again. You defined a struct in your class, but you didn't declare an instance of that struct.

Sorry to be pedantic, but reverse "define" and "declare" in the above: Difference between Definition and Declaration - GeeksforGeeks