fork download
  1. #include<iostream>
  2. #include<vector>
  3. using namespace std;
  4.  
  5. template<class T>
  6. int ExistIndex(const vector<T> v, T obj, int start = 0, int end = v.size() - 1)
  7. {
  8. std::cout << "Start: " << start << std::endl;
  9. std::cout << "End: " << end << std::endl;
  10. return -1;
  11. }
  12.  
  13. int main()
  14. {
  15. //Executing
  16. vector<int> v1 = {1, 2, 3, 4};
  17. int l = ExistIndex(v1, 3);// Although this compiles
  18.  
  19. cout << endl;
  20. return 0;
  21. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:6:67: error: local variable ‘v’ may not appear in this context
 int ExistIndex(const vector<T> v, T obj, int start = 0, int end = v.size() - 1)
                                                                   ^
stdout
Standard output is empty