Windows Forms - Instancia única - Incluir declaración
Frecuentes
Visto 448 veces
0
Cuando trato de usar la declaración #include "CFIS_Main.h" en el formulario "For_Student_Details.h", no acepta... ¿Alguien puede señalarme el error? Gracias por las ayudas..
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;
}
Mis códigos de 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();
}
Mis códigos de 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;
}
Recibir los siguientes errores
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
Del código anterior, no incluye CFIS_Main, no puedo identificar mi error, ¿alguien puede señalarme? Gracias por las ayudas
1 Respuestas
2
Tienes una referencia de encabezado circular:
- "For_Student_Details" incluye "CFIS_Main.h"
- "CFIS_Main.h" incluye "For_Student_Details"
Deberá resolver esta dependencia circular.
La forma más fácil de hacerlo es dejar solo la función declaración para button1_Click()
en "CFIS_Main.h" y mueva el definición en "MyProject.cpp", donde también incluye "For_Student_Details".
También deberá definir (o incluir el encabezado derecho) el tipo CFIS_Main
referenciado en For_Student_Details::GetForm()
(esto podría resolverse una vez que solucione el problema de inclusión circular)
Además, coloque los protectores de inclusión en sus archivos de encabezado, no en los archivos .cpp
Respondido el 12 de junio de 12 a las 18:06
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas c++ winforms visual-c++ c++-cli or haz tu propia pregunta.
Ninguno de estos archivos de inclusión define un
CFIS_Main
tipo. ¿Parece que te estás olvidando de incluir algo completamente diferente? - cdhowie