I'd like to write a constructor for one of my classes that takes a variable number of std::string arguments after a certain set of predefined arguments.
My current code looks like this:
// Audio.h
#include <string>
class Audio {
public:
Audio(std::string title, std::string author);
protected:
std::string title, author;
}
// Song.h
#include "Audio.h"
class Song : public Audio {
public:
Song(std::string title, std::string artist) : Audio(title, artist);
// I have working code to populate mFeatures from features
Song(std::string title, std::string artist, std::string *features)
: Audio(title, artist);
private:
std::string *mFeatures;
}
So I have a constructor that takes string, string and one that takes string, string, *string. I'd like to write one that takes string, string followed by an arbitrary number of strings to populate the mFeatures with.
I've looked around and found this question and this question which lay out the idea with member functions, but I haven't found an answer related to constructors.