简体   繁体   English

错误:无法从“向量”转换“标签” <std::vector<std::__cxx11::basic_string<char> &gt;&gt;' 到 ' 向量<std::__cxx11::basic_string<char> &gt;' </std::__cxx11::basic_string<char></std::vector<std::__cxx11::basic_string<char>

[英]error: could not convert 'tab' from 'vector<std::vector<std::__cxx11::basic_string<char> >>' to 'vector<std::__cxx11::basic_string<char>>'

here is my code which write a column j of a board t in an other board tab : I am a beginner so I don't understand the problem :(这是我的代码,它在另一个板选项卡中编写了板 t列 j :我是初学者,所以我不明白这个问题:(

    vector<string> colonne(vector<vector<string>> t, int j) {
    vector<vector<string>>tab;
    for(int i=0; i<t.size(); i++){
        for(int n=0; n<=j; n++){
            if(n == j){
                tab[n]=t[j];
            }
        }
    }
    return tab;
}

here is the message from the terminal:这是来自终端的消息:

error: could not convert 'tab' from 'vector<std::vector<std::__cxx11::basic_string<char> >>' to 'vector<std::__cxx11::basic_string<char>>'

Your code has numerous problems.您的代码有很多问题。 I think (based on your description) that the code you are trying to write is this我认为(根据您的描述)您尝试编写的代码是这样的

 vector<vector<string>> colonne(vector<vector<string>> t, int j) {
    vector<vector<string>> tab(t.size());
    tab[j]=t[j];
    return tab;
}

The code above creates a new board tab with the same number of columns as the first board.上面的代码创建了一个与第一个板具有相同列数的新板tab It then copies one column (with index j ) from the first board to the second board and then returns the second board.然后它将一列(带有索引j )从第一个板复制到第二个板,然后返回第二个板。

Notice though that all the other columns in the new board will have size zero.请注意,新板上的所有其他列的大小都将为零。 That seems strange to me, but maybe it is what you want.这对我来说似乎很奇怪,但也许这就是你想要的。 If not then let me know and I try to make improvements.如果没有,请告诉我,我会尝试改进。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误:没有匹配函数来调用&#39;std :: vector <std::__cxx11::basic_string<char> &gt; ::的push_back(INT&)” - error: no matching function for call to ‘std::vector<std::__cxx11::basic_string<char> >::push_back(int&)’ 错误:没有匹配的函数调用&#39;std :: vector <std::vector<int> &gt; ::的push_back(标准::矢量 <std::__cxx11::basic_string<char> &gt;&)” - error: no matching function for call to ‘std::vector<std::vector<int>>::push_back(std::vector<std::__cxx11::basic_string<char> >&)’ 错误:无法转换 'std::__cxx11::basic_string<char> ::迭代器'</char> - error: cannot convert ‘std::__cxx11::basic_string<char>::iterator’ OSX“错误:无法转换&#39;const std :: __ cxx11 :: basic_string”是什么意思 <char> “ 意思? - OSX What does “error: cannot convert 'const std::__cxx11::basic_string<char>” mean? 错误:为&#39;operator std::string {aka std::__cxx11::basic_string 指定的返回类型<char> }&#39; - Error:return type specified for 'operator std::string {aka std::__cxx11::basic_string<char>}' 错误:没有匹配的函数调用&#39;std :: map <std::__cxx11::basic_string<char> - error: no matching function for call to ‘std::map<std::__cxx11::basic_string<char> 获取“错误:无法转换 'std::__cxx11::string* {aka std::__cxx11::basic_string<char> *}' 到 'const char*' 错误,同时将路径作为参数传递</char> - Getting "error: cannot convert 'std::__cxx11::string* {aka std::__cxx11::basic_string<char>*}' to 'const char*' error while passing a path as argument (std::__cxx11::string) [T = std::__cxx11::basic_string<char> ; std::__cxx11::string = std::__cxx11::basic_string<char> ] 不能重载 - (std::__cxx11::string) [with T = std::__cxx11::basic_string<char>; std::__cxx11::string = std::__cxx11::basic_string<char>] cannot be overloaded 尝试生成随机字母错误:无法转换 'std::__cxx11::string {aka std::__cxx11::basic_string<char> }' 到 'char' 在分配</char> - Trying to generate a random letter error: cannot convert 'std::__cxx11::string {aka std::__cxx11::basic_string<char>}' to 'char' in assignment 字符串未正确复制并显示错误:无法转换 'std::__cxx11::string {aka std::__cxx11::basic_string<char> }'</char> - string not copying correctly and showing error: cannot convert 'std::__cxx11::string {aka std::__cxx11::basic_string<char>}'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM