/* * If we want to refer to a variable or function in the std namespace, * we have to use the :: operator. For example, * std::vector, std::cout, or std::endl * */ #include #include // COMMENTED THIS LINE OUT! //using namespace std; /* * Function prototypes */ void simpleVersion(); int max(std::vector nums); void moreInteresting(); /* * Main method */ int main(){ std::cout << "Calling simple version" << std::endl; simpleVersion(); std::cout << "Calling more interesting version" << std::endl; moreInteresting(); return 0; } /* * Miscellaneous Functions */ int max(std::vector nums){ int max = nums[0]; for( int i = 1; i < nums.size(); i++ ){ if( nums[i] > max ){ max = nums[i]; } } return max; } void simpleVersion(){ std::vector nums; nums.push_back(1); nums.push_back(2); nums.push_back(3); int val = max(nums); std::cout << val << std::endl; } void moreInteresting(){ std::vector nums; nums.push_back(1); nums.push_back(2); nums.push_back(3); std::vector nums2 = nums; nums[0] = 15; int val = max(nums2); std::cout << val << std::endl; }