continuing to up my game with OOP and Classes...
I have reduced my code down to just a few lines to ask this question. I am creating a class where I will need to have constructors which will allow the last variable to have an undetermined number of elements in a char array. I know that I can create multiple constructor formats for this, but can I create a single constructor format which will allow the last variable to have say anywhere from 1 to 6 elements?
Here I show how I am doing it by having multiple constructor formats for either one or two instances of values for m_delimiter. Is there a way I can do this with only one constructor format for an unknown number of m_delimiter values?
I imagine there is an easy way, but so far, my research on this has eluded me.
THANK YOU for your advice on this.
class Messages {
private:
char m_startChar;
char m_delimiters[];
public:
// constructor format for single delimiter instance
Messages(char SC, char DL1)
{
m_startChar = SC;
m_delimiters[0] = DL1;
}
// constructor format for two delimter instance
Messages(char SC, char DL1, char DL2)
{
m_startChar = SC;
m_delimiters[0] = DL1;
m_delimiters[1] = DL2;
}
};