podstawienie zmiennej string w textBox1->AppendText

0

Może mi ktoś powiedzieć dlaczego poniższy kod nie działa jak przypisuje stringa do stringa ?

string po = "test";


textBox1->AppendText(""+po);
0

Na podstawie czego stwierdziłeś że nie działa?

0
 ------ Build started: Project: Glanc MySQL TEST, Configuration: Release Win32 ------
  Source.cpp
c:\users\alien1983\documents\visual studio 2013\projects\glanc mysql test\glanc mysql test\include\cppconn\sqlstring.h(39): warning C4251: 'sql::SQLString::realStr' : class 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>' needs to have dll-interface to be used by clients of class 'sql::SQLString'
c:\users\alien1983\documents\visual studio 2013\projects\glanc mysql test\glanc mysql test\include\cppconn\exception.h(61): warning C4251: 'sql::SQLException::sql_state' : class 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>' needs to have dll-interface to be used by clients of class 'sql::SQLException'
c:\users\alien1983\documents\visual studio 2013\projects\glanc mysql test\glanc mysql test\include\cppconn\exception.h(145): warning C4251: 'sql::SQLUnsupportedOptionException::option' : class 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>' needs to have dll-interface to be used by clients of struct 'sql::SQLUnsupportedOptionException'
c:\users\alien1983\documents\visual studio 2013\projects\glanc mysql test\glanc mysql test\MyForm.h(124): error C2664: 'void System::Windows::Forms::TextBoxBase::AppendText(System::String ^)' : cannot convert argument 1 from 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>' to 'System::String ^'
          No user-defined-conversion operator available, or
          No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
Source.cpp(13): warning C4829: Possibly incorrect parameters to function main. Consider 'int main(Platform::Array<Platform::String^>^ argv)'
Source.cpp(14): warning C4551: function call missing argument list
Source.cpp(15): warning C4551: function call missing argument list
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
1
textBox1->AppendText(gcnew String(po.c_str()));
3

Używaj dotnetowego System::String zamiast std::string. Unikaj STL gdy piszesz w C++/CLI.

String ^po = L"test";
textBox1->AppendText(po);
0

Dzięki :)

1 użytkowników online, w tym zalogowanych: 0, gości: 1