// @topic T061010 std::vector demo // @brief typedef, basic_string, array, vector::at( ), try and catch, std::out_of_range #include <cstdlib> #include <iostream> #include <vector> #include <string> int do_stuff() { char* cstr = "Hello"; typedef int Color; typedef std::basic_string< char > MyStringT; MyStringT str1; std::string str2; std::basic_string< char > str3; int myarray[] = { 1, 2, 3, 4, 5 }; myarray[3] = 300; std::vector< int > vect = { 1, 2, 3, 4, 5 }; vect[3] = 300; try { vect.at(13) = 300; } catch (std::out_of_range ex) { std::cerr << "Element access out of range\n"; return 1; } std::vector< std::string > svect; return 0; } int main() { int result = do_stuff(); system("pause"); return result; }