How to write these functions?

  • Thread starter Thread starter JS.
  • Start date Start date
J

JS.

Hi, all

I use VS .NET 2003. How to write these functions ? For example,
I have tried this. But, I have got LNK2001 because of Func_1.

This:
// Func.h
void Func_1 (void);

// Func.cpp
#include "Func.h"
void Func_1 (void)
{
// Do something
}

// CA.cpp
#include "CA.h"
#include "Func.h"

void CA::Method_A(void)
{
Func_1();
}

// CB.cpp
#include "CB.h"
#include "Func.h"

void CB::Method_B(void)
{
Func_1();
}

// CC.h
.....


Or, I get LNK2005 When I remove Func.cpp from
the project and I try this.

This:
// Func.h
void Func_1 (void)
{
// Do nothings
}

I want that each class shares Func_1 with others and
don't want to make a separate DLL with Func.* .
Can I do this? Thanks.
 
You need to have separate files for function declaration
(.h) and function definition (.cpp). You can include '.h'
file in any other files. Use #ifndef. #define. #endif
in '.h' file. Use 'namespace.' also.
 
Back
Top