I want to change: unsignedchar* lpPixelArray
to std::vector<unsignedchar> vPixelArray
I allocate memory for the lpPixelArray by: lpPixelArray = (unsignedchar*)malloc(cxLength * 3 * cyLength);
However when I instantiate the object using my overridden constructor I do know the size I need the array to be: So could I check then instantiate the vector to the correct size at this point?
N.B/ I intend on making in it's own class MultipleMonitorInfo vector<SingleMonitorInfo>
With this I will create two lists, an old list and a new list. If old SingleMonitorInfo equals new: copy the vPixelArray, then delete the old SingleMonitorInfo. I am not sure how this relates to copy constructors, equals operators and smart pointers.
I am not sure what to do in this case with how I re-design my class.
Whether to instantiate the size or use resize where I previously used malloc?
If on instantiation (As the size shouldn't change after creation) should I run any validation?
Thinking of the future and how it relates to a future class:
Do I create an over-ride comparison* operator? Which checks (the name and resolution) one monitor against another? As I believe these two are the only essential variables needed.As if position changes but resolution is the same, it might not affect vPixelArray. The name refers to the szDeviceName of MONITORINFOEX structure.
If I create two instances of vector<SingleMonitorInfo>, which contains the list of all monitors, I am worried about how this might affect:
Scope of the vPixelArray (Should I use smart pointers here? Maybe an estimated size?)
I hope I have provided enough information and it is a bit clearer what I am asking. I have been reading a lot and it just gets more confused as to where to start, and implementation.
Edit: Does vPixelArray: Count as a resource?
Need a custom copy constructor and, Big Rule of Three, Five, Zero implementation?