演算子++
はと同等である必要があります+ 1
が、次の例で異なる結果が得られるのはなぜですか?
#include <iostream>
#include <string>
int main()
{
int i, n=25;
std::string s1="a", s2="a", s1p="", s2p="";
for (i=0;i<=n;i++)
{
s1p += s1;
s1 = s1.at(0) + 1;
s2p += s2;
s2 = s2.at(0)++;
}
std::cout << "s1p = " << s1p << "\n" << "s2p = " << s2p << "\n";
return 0;
}
Ouput:
s1p = abcdefghijklmnopqrstuvwxyz
s2p = aaaaaaaaaaaaaaaaaaaaaaaaaa