I have a class, whose constructor looks like this:
Chunker::Chunker(int chunkSizeX, int chunkSizeY){
chunkX = chunkSizeX;
chunkY = chunkSizeY;
}
I would like to offer the user the ability to have either chunkSizeY or chunkSizeX to have a default value (which needs to be calculated by Chunker).
I.E so they might pass in a 'AUTO' keyword or something so that the constructor knows.
Can I do something like:
Chunker::Chunker(int chunkSizeX, char chunkSizeY)
Chunker::Chunker(char chunkSizeX, int chunkSizeY)
Chunker::Chunker(char chunkSizeX, char chunkSizeY)
So that if it gets a char for one or both of the values, it knows to auto-calculate them?
I'm sure their must be a better/standard way I don't know of yet....?
intfromchara bad plan here?boost::optional, or alternatively the builder pattern as Paul Evans has described. Another common way to do this is using pointers, where a null pointer represents an omitted argument, but I find that is also not expressive.