+ 5
Which topic should I study to understand this?
9 odpowiedzi
+ 7
Pointers?
+ 5
Borislav Kalinski but it is a const char pointer, not a string object, try to call a method (e.g. "SoloLearn".length()) on it, it will not work.
That line output a copy of "SoloLearn" starting from index 5 which gives "earn" the same result can be obtained with such call:
cout << (const char*) "SoloLearn" + 5;
Please correct me if I'm wrong.
+ 4
Thanks Ipang, Pegasus and Borislav.
+ 3
Borislav Kalinski no need to apologize my friend, we are all here to learn, it's OK.
Cheers!
+ 2
Strings
Because this is not a pointer.
The logic is
"something" + "something" = "somethingsomething"
"word" + 5 = "word5"
5 + "word" = error
+ 1
Sorry I am wrong. Well I have to read again about pointers. Thanks for correcting me Ipang.
+ 1
Uttam you cannot combine an integer and a string, if you want it to say "5Sololearn", then cover the 5 in quotes.
0
this is a pointer.
If you want to write 5Sololearn just write that ;
cout<<"5 Sololearn;
I GUESS YOU MUST REVIS. YOU LESSONS AT C++ and
that's all.
0
Also Uttam, the reason it prints "earn" is because 5 is the 6th place in the string (0, 1, 2, 3, 4, 5) and it acts like an arry. If you did cout << 4 + "SoloLearn", the output would be Learn instead of earn.