| | |
Include h files
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Oct 2008
Posts: 122
Reputation:
Solved Threads: 6
Why does I encounter a compileerror when doing this.
Compile error says.
'Form3' : undeclared identifier
'Form4' : undeclared identifier
Inside of Form4.h:
Inside of Form3.h:
Compile error says.
'Form3' : undeclared identifier
'Form4' : undeclared identifier
Inside of Form4.h:
C++ Syntax (Toggle Plain Text)
#include "Form3.h" Form3 ^form3 = gcnew Form3; form3->ShowDialog();
Inside of Form3.h:
C++ Syntax (Toggle Plain Text)
#include "Form4.h" Form4 ^form4 = gcnew Form4; form4->ShowDialog();
Last edited by Liszt; Nov 9th, 2008 at 5:48 pm.
•
•
Join Date: Oct 2008
Posts: 122
Reputation:
Solved Threads: 6
That shouldn´t be a good idéa so I get over many examples how to go around this problem.
In somehow I have to use any form of a forward declaration. This is my code so far.
Still I have the compilerror for:
'Form22' : no appropriate default constructor available
I have followed an example but are not defenetive of what is going on in this code and would greatly appreciate any guidance in the code in order to really understand it.
Inside Form3.h
Inside Form3.cpp
Inside Form4.h
Inside Form4.cpp
In somehow I have to use any form of a forward declaration. This is my code so far.
Still I have the compilerror for:
'Form22' : no appropriate default constructor available
I have followed an example but are not defenetive of what is going on in this code and would greatly appreciate any guidance in the code in order to really understand it.
Inside Form3.h
C++ Syntax (Toggle Plain Text)
ref class Form4; ref class Form3 { public: Form4 ^SomeMethodA(); };
Inside Form3.cpp
C++ Syntax (Toggle Plain Text)
#include "stdafx.h" #include "Form3.h" #include "Form4.h" Form4 ^Form3::SomeMethodA() { return gcnew Form4; }
Inside Form4.h
C++ Syntax (Toggle Plain Text)
ref class Form3; ref class Form4 { public: Form3 ^SomeMethodB(); };
Inside Form4.cpp
C++ Syntax (Toggle Plain Text)
#include "stdafx.h" #include "Form3.h" #include "Form4.h" Form3 ^Form4::SomeMethodB() //SomeMethodB is not found as a member ? { return gcnew Form4; }
Last edited by Liszt; Nov 9th, 2008 at 8:25 pm.
•
•
Join Date: Oct 2008
Posts: 122
Reputation:
Solved Threads: 6
Okay, thank you. In your testprogram, did you try to open eachothers forms
or just compiling the code without the code that open forms ?
I could wonder what this meen.
If I use that line in the *.cpp files, I will have the errors:
1>.\Form3.cpp(5) : error C2059: syntax error : '<'
1>.\Form4.cpp(6) : error C2059: syntax error : '<'
If I dont use the using namespace <namespace name>; line and dont use the codes that will open eachothers forms, it will compiles fine. I dont know what this leaves the problem or solution.
or just compiling the code without the code that open forms ?
I could wonder what this meen.
using namespace <namespace name>; If I use that line in the *.cpp files, I will have the errors:
1>.\Form3.cpp(5) : error C2059: syntax error : '<'
1>.\Form4.cpp(6) : error C2059: syntax error : '<'
If I dont use the using namespace <namespace name>; line and dont use the codes that will open eachothers forms, it will compiles fine. I dont know what this leaves the problem or solution.
Last edited by Liszt; Nov 9th, 2008 at 9:16 pm.
Replace the "<namespace name>" with the namespace used in your programs. You can find this in the *.h file, for example
Yours will be different than mine -- the VC++ 2008 compiler generates the namespace name based on the project name when you created the project.
So I added this line:
#pragma once
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 "Form1.h"
namespace testform {Yours will be different than mine -- the VC++ 2008 compiler generates the namespace name based on the project name when you created the project.
So I added this line:
using namespace testform; Last edited by Ancient Dragon; Nov 9th, 2008 at 10:18 pm.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
•
•
Join Date: Oct 2008
Posts: 122
Reputation:
Solved Threads: 6
I didn´t understand that it was the projectname I should have written, sorry for that.
My projectname is simply "Form1" as in your testprogram "testform"
So now I guess I have written the *.cpp files correct. But still there is errors.
Form3.cpp
Form4.cpp
Exactly the same compileerror situation occurs anyway with this in place but I
will only have these compileerrors if I use these codes that would open eachothers
forms and the compiler only gives errors for Form4 and not Form3:
I dont know if there could be any more clues to the error.
'Form4' : no appropriate default constructor available
use of undefined type 'Form4'
left of '->ShowDialog' must point to class/struct/union/generic type
Form3.h
Form4.h
My projectname is simply "Form1" as in your testprogram "testform"
So now I guess I have written the *.cpp files correct. But still there is errors.
Form3.cpp
#include "stdafx.h"
#include "Form3.h"
#include "Form4.h"
Form4 ^Form3::SomeMethodA()
{
return gcnew Form4;
}
using namespace Form1;Form4.cpp
#include "stdafx.h"
#include "Form3.h"
#include "Form4.h"
Form3 ^Form4::SomeMethodB()
{
return gcnew Form3;
}
using namespace Form1;Exactly the same compileerror situation occurs anyway with this in place but I
will only have these compileerrors if I use these codes that would open eachothers
forms and the compiler only gives errors for Form4 and not Form3:
I dont know if there could be any more clues to the error.
'Form4' : no appropriate default constructor available
use of undefined type 'Form4'
left of '->ShowDialog' must point to class/struct/union/generic type
Form3.h
C++ Syntax (Toggle Plain Text)
Form4 ^form4 = gcnew Form4; form4->ShowDialog(); //open form4
Form4.h
C++ Syntax (Toggle Plain Text)
Form3 ^form3 = gcnew Form3; form3->ShowDialog(); //open form3
Last edited by Liszt; Nov 9th, 2008 at 11:11 pm.
•
•
Join Date: Oct 2008
Posts: 122
Reputation:
Solved Threads: 6
Thank You, I have zipped the project, the object files only took 18 kB unzipped so I left them there in case anyway.
I removed a file named: VC++ Intellisense DataBase wich took up 10.9 MB of memory.
It was not possible to upload the file with this in the folder.
I hope I am sending the project correctly.
I removed a file named: VC++ Intellisense DataBase wich took up 10.9 MB of memory.
It was not possible to upload the file with this in the folder.
I hope I am sending the project correctly.
move the implementation of button1_Click() from Form3.h to Form3.cpp. Attached are new files. It still has link problems for unresolved external functions, but you just have to implenent them in the *.cpp files.
Last edited by Ancient Dragon; Mar 10th, 2009 at 1:13 pm.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
![]() |
Similar Threads
- how to tell compiler to look in specific folder for include files? (C)
- Help using "include" inside of "echo" (PHP)
- "Cannot Open Include File" MS Visual C++ error (C++)
- question about an include file (PHP)
- How to set up include file for navbar (HTML and CSS)
- the difference between include and require (PHP)
- can't link to included files... y? (C++)
- Need Help with Side Nav Include (PHP)
- Do #include files get cached? (HTML and CSS)
- Linking files for Compilation in C++ Data Structures (C++)
Other Threads in the C++ Forum
- Previous Thread: WinAPI: UpdateResource size limit?
- Next Thread: simple tolower() and reading a text from the input
| Thread Tools | Search this Thread |
api application array arrays based beginner binary c++ c/c++ calculator char char* class classes code compile compiler console conversion count delete deploy desktop directshow dll download dynamic dynamiccharacterarray encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int java lib library linkedlist linker list loop looping loops map math matrix memory newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg simple sorting string strings studio temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets






