我已经创建了一个名为windowstestapp的Windows窗体应用程序。然后我创建了一个类调用EXTENDING.CPP,其中我添加了一个函数调用add()
,该函数从form1类创建一个对象并获取计算的文本框值。 当我尝试在form1类中创建EXTENDING对象的实例时出现问题;这不允许我创建一个对象。circuler dependancies VC++
我相信问题是在双向依赖关系。谁能帮我?
代码Form1.h: (我只用重要的代码)
namespace windowstestapp {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
#include "Extending.h"
#include "Extending.cpp"
public ref class Form1 : public System::Windows::Forms::Form
{
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
Extending ^e1=gcnew Extending();
}
};
}
extending.cpp中:
#include "StdAfx.h"
#include "Extending.h"
#include "Form1.h"
Extending::Extending(void)
{
}
double Extending::add()
{
double value=0;
windowstestapp::Form1 ^f1=gcnew windowstestapp::Form1();
value=f1->getDistance();
return value;
}
你为什么`#include`-ING .cpp文件? – robert 2011-02-02 16:53:06