#include <iostream>
#include <string>
using namespace std;

int main()
{
    string s;
    for (int i=0; i<10000; i++)
    {
        s+=1;
        for (int j=0; j<i; j++)
            {s+=0;}
    }
    cout << s;
    }

This is a code i wrote to make s=110100100010000... until 10 to the power of 10000. However in the line s+=0 i get an error saying "error: ambiguous overload for 'operator+=' in 's += 0'"

Since you are dealing with the string class what happenes if you change it from 1 and 0 to '1' and '0'

s += '1'
s += '0'

The concatenation operator for std::string doesn't convert non-string (or character) types to strings. Try this instead:

#include <iostream>
#include <string>

using namespace std;

int main()
{
    string s;

    for (int i=0; i<10000; i++)
    {
        s+="1";
        for (int j=0; j<i; j++)
            {s+="0";}
    }

    cout << s;
}

Edited 4 Years Ago by deceptikon

This question has already been answered. Start a new discussion instead.