Hi all,
why do I get an error with this line of code?
string test("a" + "b" + "c");
error C2110: '+' : cannot add two pointers
I have included the string class.
thanks.
"a" is a pointer to the letter 'a', it is not c++ class std::string. You can only use the + operator on std::string
std::string a = "a";
std::string b = "b";
std::string c = "c";
std::string text = a+b+c;
ah ok.
the reason I asked was because I needed to make a very large string(1000 chars long), and didn't want it all on one line. But then I realized that I can just read it from a file.
thanks anyway.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.