我已經創建了一個名爲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