About Store Forum Documentation Contact
Donations:
215$/mo



Post Reply 
Initializing arrays using CodeEditor
Author Message
aceio76 Offline
Silver Supporter

Post: #1
Initializing arrays using CodeEditor
Hi,

I thought I can directly initialize arrays like this:
Code:
class someclass
{
  byte somearray[100]={};
}

But it does not allow me. I expected a uniform handling like non-array variables where I can initialize at declaration.

Not very important, I just wanted to point it out.
08-09-2014 03:15 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: Initializing arrays using CodeEditor
Auto member initialization is achieved using:
Code:
class someclass
{
   someclass() : member(value) {}
}
C++ does not allow initializing arrays in that way.
08-09-2014 01:12 PM
Find all posts by this user Quote this message in a reply
aceio76 Offline
Silver Supporter

Post: #3
RE: Initializing arrays using CodeEditor
Thanks Esenthel, I do know how it works in traditional c++, but I thought CodeEditor would allow me to initialize it like it does with other variables:
Code:
class someclass
{
    byte nonarray=255;     // <- this defines and initializes it
    byte array[5]={255};   // <- won't work; have to initialize this the traditional c++ way
}

I just thought there would be some consistency. But I can spend the time writing the member initialization in the class construction no problem. I just thought the CodeEditor would save me that time. No problem though.
08-09-2014 03:13 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply