将std :: vector转换为std :: string错误

时间:2019-05-18 06:56:02

标签: c++

我正在尝试将向量数组发送到随机函数字符串,但是在发送后,我得到了no suitable user-defined conversion from "std::vector<std::string, std::allocator<std::string>>" to "std::string",我也想像这样std::cout << reverse.join(randomString(15, t), "--") << std::endl;发送它,其中t是我的abcdefghijklmnopqrstuvwxyz--ABCDEFGHIJKLMNOPQRSTUVWXYZ --0123456789-!“#$%&'()* +,-。/ :; <=>?@ [] ^ _`

typedef unsigned int uint;

std::string randomString(uint length, std::string string){
    srand(time(NULL));
    std::vector<uint> indexesOfRandomChars(length); // array of random values that will be used to iterate through random indexes of 'charIndex'
    for (uint i = 0; i < length; ++i) // assigns a random number to each index of "indexesOfRandomChars"
        indexesOfRandomChars[i] = rand() % string.length();

    std::string key = ""; // random string that will be returned by this function
    for (uint i = 0; i < length; ++i)// appends a random amount of random characters to "randomString"
    {
        key += string[indexesOfRandomChars[i]];
    }
    return key;
}


int main() {
    std::vector<std::string> t{ reverse.ascii_lowercase() , reverse.ascii_uppercase() , reverse.digits() , reverse.punctuation() };
    std::cout << reverse.join(randomString(15, t), "--") << std::endl;
    std::cin.get();
}

0 个答案:

没有答案