I have a program that I have written in C++ that compiles and works fine. I am trying to combine this with another C++ program that uses my program as a function.
The layout of my program is as follows:
The layout of their program:
And what I have done is to put my program in as one of the functions of their program. The combined program has a layout like this:
The problem is when I try to compile this, I get a lots of errors:
"x already defined in Old_Main.Obj"
So someone told me about forward declaring the function and NOT including the A2.h in B.Cpp. When I try to compile this with gcc I get:
"undefined reference to x"
Can anybody give me some advice on how to do this please?
The layout of my program is as follows:

The layout of their program:

And what I have done is to put my program in as one of the functions of their program. The combined program has a layout like this:

The problem is when I try to compile this, I get a lots of errors:
"x already defined in Old_Main.Obj"
So someone told me about forward declaring the function and NOT including the A2.h in B.Cpp. When I try to compile this with gcc I get:
"undefined reference to x"
Can anybody give me some advice on how to do this please?
Last edited: