I guess this is kinda far-fetched, but basically, I'm trying to create an instance of a class that I need to work on as if it were globally declared but initialize it once I have obtained some data from memory (previously stored data in the microcontroller). It's a project with an ESP8266 MCU that allows you to configure an led display via wifi, and for that my teammates wanted to make use of an already existing library, the problem is that in order for the user to be able to change the number of devices that they're going to use I would need to (from what I can gather, I started learning about classes a few days ago, I'm still in diapers) use the constructor again since that's when you're supposed to provide the number of devices (after that I'm not sure where I could change that variable again, I don't even know exactly what the constructor does because it's only declared in the .h file but then I wasn't able to find where is it that they define the function. There is a variable in the class that seems to have something to do with that but it's private). Originally I thought of simply passing the value to the void loop() and the other functions I use in the code, but that proved to be ineffective given that I also use another library called ESPAsyncwebserver that returns (I think that's how it works) to the void setup() (to all the places where I used 'objectoftheclass.on()' because it makes a callback) function whenever there's an HTTP request so it throws an error saying that the object was not declared in that scope (which is where I'd be creating it in). The other solution I thought of was to copy one object into an already existing global one once I had the data I needed from memory but that also throws an error.
Is there a way to allocate the memory required for a class outside of main (like a global variable) and then make an instance of that class later on but in that space? Or like, maybe a way of not using a constructor for that object until a later point in time (without really using the object at all before I use the constructor)?
I didn't wanna post the code here because it is both messy and unnecessarily lengthy for a post but tell me if it would help because I'm not quite sure if the idea of what I need here is all that clear, thanks.