In a class, is there any way to store global variables in flash memory if they are meant to be set in a constructor (and therefore not 'const') as in the following code?
class test{
public:
String a;
test(String in)
{
a = in;
}
String getA()
{
return a;
}
};
test myTest("hello");
void setup() {
Serial.begin(9600);
while (!Serial);
Serial.print(myTest.getA());
}
void loop() {
}
I assume the answer is no, but maybe there is something I haven't though of?
You need to think about when the instance of the class is created. It is NOT created at compile time. It is created at run time. At run time, flash memory is read-only. You can not do anything to put class instance data in flash memory at run time.