Thursday

C++ Syntax error: no match for 'operator=' (operand types are 'std::__cxx11::string' {aka 'std::__cxx11::basic_string'} and '') (solved)

Program:

#include <iostream>
using namespace std;

int main()
{
    srand(123);

    int vertices = 10;

    string A[vertices][vertices];

    for ( int i = 0; i < vertices; ++i )
    {
        for ( int j = 0; j < vertices; ++j )
        {
            A[i][j] = to_string{ rand()%100+1 };
        }
    }

    return 0;
}

Solution: Change braces { .. } to parentheses ( .. )

No comments:

C++32 (or C++2e), C++ 2032, Cpp 2032, g++ 2032

  Subject: C++ 2032 3 Code example for ? 2 Approximate feature suggestions: - to complete C++29 or C++ 2029 1 Web links, references Wandbox,...