// compiled by g++ -std=c++11 a.cpp #include #include #include using namespace std; int aa; // global variable string findMax(const vector &arr) { string maxValue; // local variable int * string = new string(2); // variable created by new { int k; // k is a variable inside a block // it exists only when the block is executed. } for (int i=1; i < arr.size (); i++) // i is a variable inside a block if (maxValue < arr[i]) maxValue = arr[i]; return maxValue; } int main() { vector a = {"ab", "bc", "ee"}; cout << "from findMax: "; cout << findMax(a) << "\n"; return 1; }