lundi 18 novembre 2019

why the output of the auto variable displays something not related to type?

I tried a example on Auto for variable initialization and STL in C++. For normal variable, type was printed using : typeid(var_name).name() to print i (integer) / d(float) / pi(pointer) which works fine. But while working on STL,

`#include <iostream>
 #include <vector> 
 using namespace std;

 int main() 
 { 
    vector<string> st; 
    st.push_back("geeks");
    st.push_back("for"); 

    for (auto it = st.begin(); it != st.end(); it++) 
        cout << typeid(it).name() << "\n"; 

    return 0; 
} 
`
which gives output like,
`N9__gnu_cxx17__normal_iteratorIPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt6vectorIS6_SaIS6_EEEE
N9__gnu_cxx17__normal_iteratorIPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt6vectorIS6_SaIS6_EEEE`  

and I am unable to understand the output logic behind it, can anyone explain why it is giving output like this? and thanks in advance

Aucun commentaire:

Enregistrer un commentaire