//I think this is a better way for a for loop
//for like going through arrays or something
//hope you like it :)
//be sure to do #include <set>
int main()
{
set<char> letters = {'A', 'B', 'C'};
for (auto itr = letters.begin(); itr != letters.end(); ++itr){
cout << *itr << endl;
}
}
//When using auto variables, the data type is decided in initialisation
#include <iostream>
using namespace std;
int main() {
auto IntegerVar=25; //creates integer type variable
auto FloatVar=26.77; //creates float type variable
auto StringVar="Hello"; //creates string type variable
auto CharVar="C"; //creates char type variable
cout<<"CREATING VARIABLES USING AUTO DATA TYPE
";
cout<<"Integer: "<<IntegerVar<<endl;
cout<<"Float: "<<FloatVar<<endl;
cout<<"String: "<<StringVar<<endl;
cout<<"Char: "<<CharVar;
cout<<"
";
return 0;
}
int foo = 0;
auto bar = foo; // the same as: int bar = foo;
// type of bar is the type of the value used to initialize it
for (auto&& [first,second] : mymap) {
// use first and second
}
for(auto x: myVector){
cout<< x << " ";
}