what is the meaning of auto and why you used auto …
Datatype auto in case of stl
hello @vishal_sangal_123
auto is a keyword in c++ , that automatically detects the datatype of variable.
example->
#include<iostream>
#incllude<vector>
using namespace std;
int main() {
vector<int> vec(10); // Auto deduce type to be iterator of a vector of ints.
for(auto it = vec.begin(); it != vec.end(); vec ++)//here auto will automatically detecst the datatype
{
cin >> *it;
}
return 0;
}
```
1 Like
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.