Not able to include a file that includes the other

So currently i am trying to #include "MyForm.h" in "MyForm1.h" but "MyForm.h" already has #include"MyForm1.h" in the top of it and for some reason when i try to put the include in MyForm1 i get a multitude of errors

1
2
3
4
5
6
7
8
9
10
11
12
13
//Errors 
Severity	Code	Description	Project	File	Line	Suppression State
Error	C2061	syntax error: identifier 'MyForm1'	CppWinForm2	2015\projects\cppwinform2\cppwinform2\MyForm.h	168	
Error	C2227	left of '->ShowDialog' must point to class/struct/union/generic type	CppWinForm2	2015\projects\cppwinform2\cppwinform2\MyForm.h	169	
Error	C2065	'MyForm1': undeclared identifier	CppWinForm2	2015\projects\cppwinform2\cppwinform2\MyForm.h	168	
Error	C2065	'f2': undeclared identifier	CppWinForm2	2015\projects\cppwinform2\cppwinform2\MyForm.h	168	
Error	C2065	'f2': undeclared identifier	CppWinForm2	2015\projects\cppwinform2\cppwinform2\MyForm.h	169	
	
//The code the errors refer to\
				this->Hide();
				MyForm1^ f2 = gcnew MyForm1();
				f2->ShowDialog();
				this->Close();

As as soon as i remove #include "MyForm.h" from MyForm1.h these errors no longer exist, the reason iwant to connected the two files is so that i can take the input from a textbox on MyForm and open a New form (MyForm1) which has a label that says what they typed.
Google "include circular dependency"

This code is not C++.

Use better names.
Looks like some microsoft visual studio stuff. It's not standard C++ for sure.

Typically when files are dependent upon each other in C++, the design is re-imagined to avoid such a situation, or forward declarations are used http://stackoverflow.com/questions/4757565/what-are-forward-declarations-in-c
Topic archived. No new replies allowed.