|
-
July 3rd, 2007, 01:16 PM
#1
using different files in one project
hello, i created a form which has buttons and textfields in it. And i have another .cpp and .h files which i added to resource and header part of the project. I want to use methods in those files in my buttonpressed methods. but i have problems,
1)When i didn't write #include "myfile.h" compiler can't see the global methods in the .h file.
2)When i include the .h file, it gives redefinition error.
how should i use those methods? Should i c/p them into the form.h ?
thanksalot
-
July 3rd, 2007, 03:00 PM
#2
Re: using different files in one project
Put your global functions and other stuff in namespaces and then use it.
A Person who is polite is given goodness and a person who is away from Politeness is away from Goodness.
NAUMAAN
-
July 3rd, 2007, 03:25 PM
#3
Re: using different files in one project
 Originally Posted by tymaut
2)When i include the .h file, it gives redefinition error.
Redefinition of what?
Why did you define that thing in your header file?
Could you simply declare it there and define it in a .cpp file instead?
Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
Convenience and productivity tools for Microsoft Visual Studio:
FeinWindows - replacement windows manager for Visual Studio, and more...
-
July 4th, 2007, 04:30 AM
#4
Re: using different files in one project
redefinition of the global variables i declared in the beginning of the header file.
i included the global variables and methods in the namespace, now compiler can see them but when i want to use a method i defined its prototype in namespace and declared in the cpp file, it gives
form1.obj : error LNK2019: unresolved external symbol "void __clrcall form1::fileToChar(void)" (?fileToChar@form1@@$$FYMXXZ) referenced in function "private: void __clrcall form1::Form1::button1_Click(class System::Object ^,class System::EventArgs ^)" (?button1_Click@Form1@form1@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
-
July 5th, 2007, 12:33 PM
#5
Re: using different files in one project
 Originally Posted by tymaut
redefinition of the global variables i declared in the beginning of the header file.
This question comes up almost daily.
Check out this thread
 Originally Posted by tymaut
i included the global variables and methods in the namespace, now compiler can see them but when i want to use a method i defined its prototype in namespace and declared in the cpp file, it gives...
Compiler saw them all the time. More than it needed to, actually 
Namespace does not help you fix redefinition problem (unless you have DIFFERENT variables that have the same name).
To fix your unresolved external error please show how you declared and defined that function, and how you call it.
Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
Convenience and productivity tools for Microsoft Visual Studio:
FeinWindows - replacement windows manager for Visual Studio, and more...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|