C++ Help v.STD to System
I don't know if theres anyone on HAN that knows much C++ or anything.
I'm working on a final project. My partner and I are making a calculator. I'm doing the dialog and hes doing most of the functions. The functions are using namespace STD while my dialog is using a namespace that Visual Studio made. I'm making my dialog with Windows Forms.
What I need to do is pass System::string to std::string and then std::string to system::string. Is this possible? Can anyone shed some light on this or toss out some code snippets?
I'm working on a final project. My partner and I are making a calculator. I'm doing the dialog and hes doing most of the functions. The functions are using namespace STD while my dialog is using a namespace that Visual Studio made. I'm making my dialog with Windows Forms.
What I need to do is pass System::string to std::string and then std::string to system::string. Is this possible? Can anyone shed some light on this or toss out some code snippets?
I read somewhere that if I use this:
it should work. However my string is in the private section of a class. Normally I would just go c.get_ans() and it would return the string.
I tried
but it still says "error C2440: 'initializing' : cannot convert from 'const char *' to 'System::String ^'"
Edit: Nobody knows C++? Damn...
Code:
std::string my_string = "Some text"; System::String* string = my_string.c_str();
I tried
Code:
System::String* ans1 = c.get_ans().c_str();
Edit: Nobody knows C++? Damn...
c_str() returns a pointer to a constant. you are trying to initialize a non-constant variable to a constant. try setting the return value equal to a const variable to be used as a buffer possibly.



h: