Quick A: Write a constructor that takes a std::initializer_list
.
See the link for the nice longer answer:
how to implement an initializer list for user defined type? (analogus to std::vector initializer list)
std::vector
can be initialized as
std::vector<std::string> words1 {"the", "frogurt", "is", "also", "cursed"}; refNow if want to achieve the similar functionality for one of my types how do I go about doing it? How should I implement the constructor for this functionality?
Add a Comment
Comments are closed.