locked
What is wrong with this code? RRS feed

  • Question

  • Hello,

    I'm learning C++ but i'm not sure what it wrong with the following code:

    #include <iostream>
    #include <string>
    using namespace std;
    
    string docname("Untitled");
    
    private: System::Void newToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) 
    		 {
    			 MessageBox::Show("Do you want to save your changes to " + docname + "?", "Save Changes?");
    		 }
    This is a windows forms application and I am trying to get the docname string to show in the messagebox. I get the following error:

    ***Error    1    error C2665: 'System::Windows::Forms::MessageBox::Show' : none of the 21 overloads could convert all the argument types***


    Thanks,

    Steve

    Thanks, Steve
    Monday, August 24, 2009 3:29 PM

Answers

  • The variable docname is now an std::string. Change it to a System::String^ because there's no real need to mix types here.
    http://blog.voidnish.com
    • Marked as answer by nobugz Wednesday, August 26, 2009 2:14 AM
    Monday, August 24, 2009 3:41 PM