0

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.

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by Danny_501
1

"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;
0

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.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.