Why this .net c++ code fails to compile ? HELP new learner !!!

J

Jack

Start fresh new default Windows .NET application and modify the
Form1 default constructor as follows (file "form1.h"):

Form1
{
InitializeComponent();
MessageBox::Show("Message","Test"); // This is new line added by me
}




The above code works OK. Now modify the code as follows:




In file "form1.h" change Form1 constructor from definition to
declaration as follows:

Form1();

In file "form1.cpp" add definition as follows:

Form1::Form1()
{
InitializeComponent();
MessageBox::Show("Message","Test");
}

Despite the fact that the #include "form1.h" is in form1.cpp this
change fails to compile in the above form or even in the form as
below:

Form1::Form1()
{
InitializeComponent();
System::Windows::Forms::MessageBox::Show("Message","Test");
}

The later version even helps you to build this code by pop-up cues,
but still fails to match proper .NET version of MessageBox during
compilation here and tries to use Windows API call instead which is
not what I want here.

What am I doing wrong ? Some expert, please help !!!

Jack
 
F

feng

//undefine MessageBox macro
#undef MessageBox
Form1::Form1()
{
InitializeComponent();
MessageBox::Show("Message","Test");
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top