Board index » cppbuilder » functions written in other file

functions written in other file

Hi,

I like to write some functions of my Project into another file. My
problem is that is doesn't know correctly how to do.

I would do it like this:

// extra.h

void __fastcall newfunc();

// extra.cpp

void __fastcall newfunc()
{
Beep();

Quote
}

Later I would include the extra.h into my project und call the function.
Bis this I think won't works.
Please tell me whats to change and how to call the functions.

Philipp

 

Re:functions written in other file


Hi Philipp,

Did you make sure that the "extra.cpp" is a unit the project? I'm assuming
that the error that you are getting is a linker error.

bob

von der Born <vonderB...@t-online.de> wrote in message
news:3889D718.3BBF95E4@t-online.de...

Quote
> Hi,

> I like to write some functions of my Project into another file. My
> problem is that is doesn't know correctly how to do.

> I would do it like this:

> // extra.h

> void __fastcall newfunc();

> // extra.cpp

> void __fastcall newfunc()
> {
> Beep();
> }

> Later I would include the extra.h into my project und call the function.
> Bis this I think won't works.
> Please tell me whats to change and how to call the functions.

> Philipp

Re:functions written in other file


Write the header and source in a directory of your choice.
In the application in which you want to use the function(s) choose
Project|Add To Project.
Browse and select the .cpp file you need.
Finally in .cpp file which will call the function you need to include the
header from your extra.h
(this can be done using the <include unit header> option in the File menu.

Paul
von der Born <vonderB...@t-online.de> wrote in message
news:3889D718.3BBF95E4@t-online.de...

Quote
> Hi,

> I like to write some functions of my Project into another file. My
> problem is that is doesn't know correctly how to do.

> I would do it like this:

> // extra.h

> void __fastcall newfunc();

> // extra.cpp

> void __fastcall newfunc()
> {
> Beep();
> }

> Later I would include the extra.h into my project und call the function.
> Bis this I think won't works.
> Please tell me whats to change and how to call the functions.

> Philipp

Other Threads