• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 179
  • Last Modified:

Function in a .h file

I have a function that I need to call from a lot of different classes and functions throughout my application. When I place the function in a header file and include that header file in all the classes, I get a link error saying the function has already been defined. I use the #if !defined, #endif... statements but that doesn't seem to help. How can I use this function in several places without having to duplicate the code? I am using MSVC++ 6.0. Thanks.
0
jmnolan
Asked:
jmnolan
1 Solution
 
chensuCommented:
// .h
// The declaration is here.

void myfunc();


// .cpp
// The definition is here.

void myfunc()
{
....
}
0
 
jmnolanAuthor Commented:
Thanks, I knew it was something dumb.
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now