I have a function inside my program to count the number of the files in a given directory. The function takes the input parameters as the name of the directory and the extension of the filename (type of files which have to counted in the directory).
I want to make it generic so that the caller of the function can specify any number of file extensions which can be taken as the input parameters and then the specific files having those extensions are counted.
void getNames(string dirName, string fileExtension1, string fileExtension2, string fileExtension3){
vector<string> fileNames = //do some operations
if(fileType == fileExtension1 || fileType==fileExtension2....){
//increase count
}
return fileNames;
}
How do I change this function so that it takes any number of parameters and then the uses the same parameters inside the function to calculate the number of files?