Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

7
  • 1
    You may have provided enough info – I don't know – but I think it would be helpful if you edit your question to include a Minimal, Complete, and Verifiable example of code, as well as the snippets. Otherwise, anyone who wishes to test an answer before posting it has to do the busy work of putting the snippets together. Commented Feb 23, 2017 at 17:54
  • My concept of what new does is: allocate memory for an object and construct the object. Doesn't *Presets = (Preset*)malloc(sizeof(Preset) * NumPresets); allocate memory for an array of Presets and for ... Presets[p] = new Preset(...) allocate the same amount again? (This would be a problem, not the problem.) Commented Feb 23, 2017 at 17:59
  • I'm new to Arduino, but isn't it possible to use a 2 dimensional array (of Pattern)? Or does Device has more properties than only a list an array of patterns? Commented Feb 24, 2017 at 0:20
  • @jwpat7 I added a complete version of the code. If i remove the New keyword from the objects initialization it complains that "cannot convert 'Preset' to 'Preset*' in assignment", so i tought it was still necessary despite the malloc. Commented Feb 24, 2017 at 8:57
  • @MichelKeijzers each class, LedDevice, Pattern and Preset has other attributes and functions, therefore i need a class for each, even a structure won't do. I'm already having issues initializing 1 dimensional array, if i go for 2 i guess it will be even worse Commented Feb 24, 2017 at 8:59