I need to create an interactive session in C++ where user can test a class I created. That includes creating objects of that class with its different constructors. One of them is a collection constructor using initializer_list.
In my code I can run:
MyClass example = {1, 2, 3, 4};
Now I need to find the method to use it during interactive session. Somehow I need to fill the {} with the input provided by the user. User can pass up to 100 argments in that list, so I probably need some kind of a loop solution to my problem. Something working like (Sorry for C++/Python pseudocode mixture):
MyClass example = {a for a in user_input};
Do you know anything I can use to solve this?
Aucun commentaire:
Enregistrer un commentaire