473,325 Members | 2,860 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

How to write these functions?

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.

Nov 16 '05 #1
1 918
nn
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.
-----Original Message-----
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.

.

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Stumped and Confused | last post by:
Hello, I really, really, need some help here - I've spent hours trying to find a solution. In a nutshell, I'm trying to have a user input a value in form's textfield. The value should then be...
24
by: gswork | last post by:
Let's write a c program, without knowing what it does... Some of you may recall Jim Roger's excellent series of posts (on comp.programming) exploring the implementation of common software...
16
by: ben beroukhim | last post by:
I have huge number of legacy code which use standard files functions. I would like to pass a memory pointer rather than a FILE pointer. I am trying to use FILEs in the code to refer to memory...
27
by: Sune | last post by:
Hi! Pre-requisites: ------------------- 1) Consider I'm about to write a quite large program. Say 500 K lines. 2) Part of this code will consist of 50 structs with, say, no more than at most...
7
by: Ritu | last post by:
Hi All, Can any body please tell me how i can write a device driver using CSharp. Thanks, Ritu
8
by: a | last post by:
I have a struct to write to a file struct _structA{ long x; int y; float z; } struct _structA A; //file open write(fd,A,sizeof(_structA)); //file close
0
by: brm6546545 | last post by:
I am trying to get some C code to work on .net C++ compiler int writeDatagram(int sock, char *buf, int length) { return write(sock, buf, length); } void killConnection(int sockd) {...
10
by: roberts.noah | last post by:
Using ostringstream the buffer gets increased to allow data to be appended when needed at least when you call <<. I was under the impression that write() also did but I am having problems that...
20
by: Newbie Coder | last post by:
MFC Application VC++.NET 2003 I have a certain registry key (HKCU\Software\MyKey) that contains between 30 & 64 string values I need to write a '*' to all those 30 - 64 string values under...
23
by: asit dhal | last post by:
hello friends, can anyone explain me how to use read() write() function in C. and also how to read a file from disk and show it on the monitor using onlu read(), write() function ??????
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.