dimanche 26 mai 2019

Where is the fault?

complier error Error C2440 '=': cannot convert from 'const std::basic_string,std::allocator>' to 'const char *'

int main(void)
{

    /*
    complier error
    Error   C2440    '=': cannot convert from 'const std::basic_string<char,std::char_traits<char>,std::allocator<char>>' to 'const char *' 
    primer  C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.22.27706\include\xutility  1745
    */
    list<string> names = {"A","B"};
    vector<const char*> vnames;
    vnames.assign(names.cbegin(), names.cend());//OK
    /*for (auto it = names.cbegin(); it != names.cend(); ++it)
    {
        cout << *it << endl;
    }*/
    for (auto it = vnames.cbegin(); it != vnames.cend(); ++it)
    {
        cout << *it << endl;
    }
    cout << "hello world" << endl;
    return 0;
}

Aucun commentaire:

Enregistrer un commentaire