Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

General Help in Putting things in the right place!

Status
Not open for further replies.

ncwizad

Programmer
Aug 25, 2005
10
0
0
GB
Hello,
I'm new to MFC and i'm confused!

I have some procedures that need to be accessed in several
areas of a program, which is the best source or Header file to write them in? or if i create a new file, how do i make sure the other bits of the program see them correctly.

Thanks
 
This isnt anything todo with MFC, you could do with learning the basics of C/C++ programming.

There are tons of good resources available on the internet, just try searching google for beginners guide to C/C++ programming.

(If you are interested in MFC, then you should look up just C++ instead of C).

Skute

"There are 10 types of people in this World, those that understand binary, and those that don't!"
 
i dont think i'm very hot but i do claim to know at least the basics of C++, maybe i didnt phrase my question too well.

Visual C++ seems to create a .cpp file for each class but i'm confused as to how all these files interact (especially at compile and linkage time)
For instance the project is 'Post' so VC++ creates Post.cpp, and PostDlg.cpp with associated header files.
I've created my own class called variables (variables.cpp and variables.h) I now want to write functions that can access the variables class from within PostDlg. Wheres the best place to declare and write the functions?

If anyone knows of a tutorial site that explains all this please let me have it, (i've tried msdn and it goes straight over my head!).

 
You need to create an instance of your variables class in the Post class (include the variables header). Then you create public functions in your variables class that the post class can see/call.

Robert Cumming
 
Post.h/.cpp = Main application files
PostDlg.h/.cpp = The class which represents your application's dialog on screen

If you want a variable class, create a new class with the project wizard, it will create a new set of .h/.cpp files for you with a constructor and destructor already in.

Then in CPostDlg you can create an instance of your CVariable class, then when you click on a button in your dialog, you can call the member functions of your variable class:

e.g.

void CPostDlg::OnBnClickedGo()
{
m_pVars->DoSomething();
}


Skute

"There are 10 types of people in this World, those that understand binary, and those that don't!"
 
Yea Thanks i sort of get that, but do all functions need to be members of a class? i have a few functions that i want to be able to use globally.
where do i declare them and where do i write the code?... inside the Post class?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top