diff --git a/main.cpp b/main.cpp index c9432f6..b7c4cc1 100644 --- a/main.cpp +++ b/main.cpp @@ -1,42 +1,49 @@ +#include +#include +#include #include -#include -#include -class A { -public: - A() { - std::cout << "Class A Created\n"; - } - virtual ~A() { - std::cout << "Class A Destroyed\n"; - } -}; +using string = std::string; +using svector = std::vector; -class B { -public: - B() { - std::cout << "Class B Created\n"; - } - ~B() { - std::cout << "Class B Destroyed\n"; - } -}; +string prompts(const string&,bool*); +void sortVStringsAsc(svector &v); -class C : public A { - B b{}; -public: - C() { - std::cout << "Class C Created\n"; +int main() { + svector inputs; + bool s{true}; + while (s) { + auto inp = prompts("Enter a string (Invalid to begin processing): ",&s); + if (s) inputs.push_back(inp); } - virtual ~C() { - std::cout << "Class C Destroyed\n"; - } -}; - -int main() -{ - A v{}; - B w{}; - C x{}; + sortVStringsAsc(inputs); + for (const auto &c : inputs) std::cout << c << "\n"; return 0; } + +void sortVStringsAsc(svector &v) { + sort(v.begin(), v.end(), [] (const string &x, const string &y) {return x.length() < y.length();}); +} + +double sumList(const std::vector &l) { + double sum = 0.0; + for (const auto &c : l) sum += c; + return sum; +} + +class A { + std::vector s; +}; + +string prompts(const string &message, bool *success) { + string tr{""}; + *success = false; + std::cout << message; + if (!(std::cin >> tr)) { + std::cin.clear(); + std::cin.ignore(); + return ""; + } + *success = true; + return tr; +}