First of all, you should avoid using such arrays in C ++, instead you should use std::vector<unsigned char> .
about the const keyword. It simply tells the compiler and the one who reads the code that this member / variable / parameter should not be changed.
With pointers there, the position of the const keyword is important:
( EDIT : found Greyson's answer where I borrowed this part)
The const keyword denotes the part to the left of it as a constant (if it is at the beginning, it matches the type to the right of it, so const unsigned char and unsigned char const are equal)
To mark the pointer as const, you do this (the content is still changing):
unsigned char * const aConstantPointerToAMutableContent;
To mark the content as const, you will do the following:
const unsigned char * aPointerToAConstantContentA; unsigned char const * aPointerToAConstantContentB;
To mark as a constant:
const unsigned char * const aConstantPointerToAConstantContent;
This is a hint for the compiler and user to make it clear what is done or not done with the data. if the parameter is const unsigned char * , then the user will know that this content will not be changed if it is passed.
because the const keyword is only a label, if something can be changed, it does not affect the size of the size itself, so for delete it should not have an effect. (see answers and comments. Ease of race in orbit , as well as " Is const_cast safe? " may be for interrest).
But what I don't like about your code is that the constructor is publicly available. I could call it directly, but since the const unsigned char* array parameter is const unsigned char* array , I would not expect the class to change the contents or delete it when destroyed. (I would not expect direct object creation to behave differently using factory.)
So, I would make the factory method as the static method of this class and make the constructor protected .