I'm not a c++ developer but my current project is updating a legacy c++ application.
All throughout the application I see append statements that take two arguments..
strTemp.append( cDollars, len );
I'm trying to understand the C++ language and how it is implemented in this legacy application.
I'm stuck on the append function.
I can get it to work with a three arguments..
#include <iostream>
#include <string>
using namespace std;
int main(){
string msg = "Hi There!";
string msg2;
msg2.append(msg,0, 2);
cout << msg2;
cout << "\n";
system("pause");
return 0;
}
This returns...
Hi
Press any key to continue . . .
I can get append to work with a single argument..
#include <iostream>
#include <string>
using namespace std;
int main(){
string msg = "Hi There!";
string msg2;
msg2.append(msg);
cout << msg2;
cout << "\n";
system("pause");
return 0;
}
This returns...
Hi There!
Press any key to continue . . .
The problem is that I can't get this to work with a two arguments...
#include <iostream>
#include <string>
using namespace std;
int main(){
string msg = "Hi There!";
string msg2;
msg2.append(msg, 1);
cout << msg2;
cout << "\n";
system("pause");
return 0;
}
--------------------Configuration: Program - Win32 Debug--------------------
Compiling...
Program.cpp
C:\USERS\E1009028\DOCUMENTS\VISUAL STUDIO 6 PROJECTS\SCRATCH\Program\Program.cpp(11) : error C2664: 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &__thiscall std::basic_string<char,struct std::char_traits<c
har>,class std::allocator<char> >::append(const char *,unsigned int)' : cannot convert parameter 1 from 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' to 'const char *'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
Error executing cl.exe.
Program.exe - 1 error(s), 0 warning(s)
This is Visual Studio 6 (did I mention the legacy application?).
Can anyone tell me what I'm missing?
Thanks,