I am trying to learn C++ in VS 2010 Express. I want to transfer text from one textbox on a form to another when the Execute button is pressed. However, I want to learn how to do this in a different cpp file.
In the header file Form1.h, I have the code:
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
this-> textBox2-> Text = returnString(this-> textBox1 -> Text);
with #include "String_Copy.cpp"
at the top.
In String_Copy.cpp, I have:
#include "stdafx.h"
using System::String;
String^ returnString(String^ input)
{
return input;
}
But I get the compile error:
String_Copy.obj : error LNK2005: "class System::String ^ __clrcall returnString(class System::String ^)" (?returnString@@$$FYMP$AAVString@System@@P$AAV12@@Z) already defined in Forms_Call.obj
I have no idea what I am doing wrong. Any suggestions?
Thanks.