又是 C++的错误

来源:百度知道 编辑:UC知道 时间:2024/06/20 18:32:19
/**
NOTE:

#include <iostream>

using namespace std;

int main()
{
int total;// The variable total should be initialized with type double
cout << "Please enter a number: ";
double x1;
cin >> x1;
cout << "total = " << total << "\n"; //trace message
total = total + x1;
cout << "total = " << total << "\n"; //trace message
cout << "Please enter a number: ";
double x2;
cin >> x2;
total = total + x2;
cout << "total = " << total << "\n"; //trace message
total = total / 2;
cout << "total = " << total << "\n"; //trace message
cout << "The average is " << total << "\n"; <

我猜你的项目里有多个代码文件,而除了你贴在上面的还有一个代码,该代码中也有main函数,一个项目的入口函数只能有一个,多个main就报错了。_main already defined in Haoyu Wu A1.1.obj 可能是你之前编译过的残留下来的中间代码文件,把它删了看看。