VC + + compiler error

Category: C/C++ -> C++ Author: edijoe Date: 2009-09-13 21:00:50
 
edijoe
2009-09-13 21:00:50
Younger beginner VC, existing a program compiler error, please take a look (two cpp file):

/ * main.cpp main program * /
# include <iomanip.h>
# include "abc.cpp"
void main ()
{
double a, b, c;
double averageValue ;
a = 2; b = 3; c = 4;
averageValue = AVE (a, b, c);
cout << "averageValue:" << averageValue << endl;
averageValue = AVE (a, b +1, c +2);
cout << "averageValue:" << averageValue < ; <endl;
}

/ * abc.cpp * /
double AVE (double x, double y, double z)
{
return (x + y + z) / 3;
}

two cpp files compile successfully, but build the following error message:
bc.obj: error LNK2005: "double __ cdecl AVE (double, double, double)" (? AVE @ @ YANNNN @ Z) already defined in main . obj
Debug / bx.exe: fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe.

I do not know what is the reason?
caicai2013
2009-09-13 21:40:47
to # include <iomanip.h> to # include <iostream.h>
cfy_hbrhbr
2009-09-13 21:57:56
to # include <iomanip.h> instead
# include <iostream>
using namespace std;
after Dev-C + + running under good
wz32872024
2009-09-13 22:24:43
impossible Well, I is that you can ah. Did not you put two files in the same directory as the?
cfy_benlu
2009-09-13 22:51:36
I know, VC6 AVE Curry has a built-in function, resulting in a conflict, you put AVE function name change other on ok.
y19193020
2009-09-13 23:24:39
bc.obj: error LNK2005: "double __ cdecl AVE (double, double, double)" (? AVE @ @ YANNNN @ Z) already ; defined in main.obj
redefinition
cdcheng112
2009-09-13 23:54:03
my main.cpp is not defined in the AVE function, just use include this file contains abc.cpp, AVE function abc.cpp defined, this is also redefined? should be how to correct?
zhendemixi
2009-09-14 00:19:28
to # include <iomanip.h> to # include <iostream.h> useless
LZJ_JOY
2009-09-14 00:59:18
two files are placed in the same directory, I use the Visual C + + 6.0, the compiler will not have a problem?
xzx2466
2009-09-14 01:23:06
not clear where the problem lies, I copied your code After working on my side.