[Solved] C++ Why is my program throwing an exception?
You made variable with name that matches type name (string variable, string type?). Plus there is issue that you return pointer to object with local scope of life. That is UB. Using iterators your function would work like this: const string shortest_string(initializer_list<string> strings) { if(!strings.size()) return string(); auto shortest_one = strings.begin(); for (auto it = … Read more