0

#include "CFIS_Main.h" ステートメントをフォーム "For_Student_Details.h" で使用しようとすると、受け入れられません...誰かが私に間違いを指摘できますか? 助けてくれてありがとう..

MyProject.cpp
// MyProject.cpp : main project file.

#include "stdafx.h"

#ifndef CFIS_Main_h
#define CFIS_Main_h
#include "CFIS_Main.h"
#endif

using namespace MyProject;

[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
    Application::EnableVisualStyles();
    Application::SetCompatibleTextRenderingDefault(false); 

    // Create the main window and run it
    Application::Run(gcnew CFIS_Main());
    return 0;
}

MdiParent からのマイ コード

//CFIS_Main.h  IsMdiContainer = True

#include "For_Student_Detials"


private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
For_Student_Detials^ MyStudentDet= For_Student_Detials::GetForm(true,this);
MyStudentDet->MdiParent=this;
MyStudentDet->FormBorderStyle=System::Windows::Forms::FormBorderStyle::None;
MyStudentDet->Dock=DockStyle::Fill;
MyStudentDet->Show();
}

MdiChild からのマイ コード For_Student_Details

#include "CFIS_Main.h"  Why Not included...?????

public: static For_Student_Details^ For_Student_Details::_instance = nullptr;
public: static For_Student_Details^ For_Student_Details::GetForm(bool^ IsMDIChild, CFIS_Main^ MyInstFrm) {
if (_instance == nullptr)
    _instance = gcnew For_Student_Details();

if (_instance->IsDisposed)
    _instance = gcnew For_Student_Details();

if (IsMDIChild)
    _instance->MdiParent = MyInstFrm;

return _instance;
} 

以下のエラーを受け取る

error C2061: syntax error : identifier 'CFIS_Main'
error C2065: 'MyInstFrm' : undeclared identifier
error C2660: 'CashFlow_InformationsSystem::For_Loan_Details::GetForm' : function does not take 2 arguments

上記のコードから, CFIS_Main が含まれていません. 間違いを特定できません. 誰か指摘してくれませんか? 助けてくれてありがとう

4

1 に答える 1

2

循環ヘッダー参照があります:

  • 「For_Student_Details」には「CFIS_Main.h」が含まれています
  • 「CFIS_Main.h」には「For_Student_Details」が含まれています

この循環依存を解決する必要があります。

これを行う最も簡単な方法は、"CFIS_Main.h"の関数宣言のみを残し、定義を "MyProject.cpp" に移動することです。ここには、"For_Student_Details" も含めます。button1_Click()

CFIS_Mainまた、参照されるタイプを定義する (または正しいヘッダーを含める) 必要がFor_Student_Details::GetForm()あります (これは、循環インクルードの問題を修正すると解決される可能性があります)。

また、.cpp ファイルではなく、ヘッダー ファイルにインクルード ガードを配置します。

于 2012-06-12T17:45:34.233 に答える