I am trying to write a program an I've gotten stuck. It is fairly simple. I have a windows form and a 'classTester01' class. What I am trying to do is make it so that when the button is clicked, the text on the button is changed to the value in the variable 'buffer'. The problem is I keep getting these errors. I have included my code and I appreciate any help you can offer.
I would also like to know if this is the best way to do it; having one class for the character and using the windows form to manipulate the data in an instance of that class.
c:\users\support\documents\visual studio 2010\projects\classtest01\classtest01\classTester01.h(16): error C4368: cannot define 'buffer' as a member of managed 'classTester01': mixed types are not supported
c:\users\support\documents\visual studio 2010\projects\classtest01\classtest01\mainForm.h(96): error C2678: binary '=' : no operator found which takes a left-hand operand of type 'std::string' (or there is no acceptable conversion)
number = 7;
buffer = "Clicked";
number = 21;
std::string convertInt(int num)
std::ostringstream ostr; //output string stream
ostr << num; //use the string stream just like cout,
//except the stream prints not to stdout but to a string.
std::string theNumberString = ostr.str(); //the str() function of the stream
//returns the string.
I'm not sure how or why the class is managed but it wasn't my intention ( I am quite green...). How do I 'stick with standard C++ language'? Does that mean I can't use window like object and must use the console?
You can mix managed and unmanaged code, but it can be tricky. Change the declaration of buffer to a std::wstring* (System::Strings don't have a ctor to convert from a const char* but does for const wchar_t*) and initialize it in the ctor.
Also button1->Text = newTester->buffer; this won't work, you need to convert a std::string to a System::String like