I'm having a little problem with trying to define a label outside of the header file. I've started to try to learn C++ only three days ago, so I may have done a pretty obvious mistake here that I've not noticed. So far I've not managed to get this to work.
I wanna define the text in MIDCSrc.cpp, whilst the declaration of the label is in MIDC.h. So far, what I've done in MIDC.h is:
*MIDC.h*
#include "MIDCSrc.cpp"
*VS Auto-generated code*
private: System::Windows::Forms::Label^ label1;
*VS Auto-generated code*
private: System::Void label1_Click(System::Object^ sender, System::EventArgs^ e)
{
textfunc2(label1);
}
And in MIDCSrc.cpp is:
#include "MIDC.h"
namespace MIDC
{
void textfunc2(System::Windows::Forms::Label^ aLabel)
{
aLabel->Text = "Wow!";
}
}
(I'm using Visual Studio 2017 Community)
The problem is, I can't even test it to see it fail miserably because it gives me a "Error C2084 function 'void MIDC::textfunc2(System::Windows::Forms::Label ^)' already has a body"
As I said, I'm sorry if this is a obvious mistake, but I can't figure this lovely error. If there is something (and I know there is) wrong with the code aside the body error, if possible, tell me. Gotta fix this.
Thanks to whoever replies :-)