C++ Netbeans发出重复错误

C++ Netbeans发出重复错误,c++,c++11,netbeans,netbeans-7,C++,C++11,Netbeans,Netbeans 7,我已经下载了:XQuartz、Xcode和netbeans7.4。我正在尝试运行一个简单的程序。我根据Netbeans网站的指示正确创建了一个新项目,我发现以下代码错误: #include <iostream> /* Include header file to do input and output */ #include <fstream> /* Include the library to read and write files */ #includ

我已经下载了:XQuartz、Xcode和netbeans7.4。我正在尝试运行一个简单的程序。我根据Netbeans网站的指示正确创建了一个新项目,我发现以下代码错误:

#include <iostream>    /* Include header file to do input and output */
#include <fstream>     /* Include the library to read and write files */
#include <iomanip>    /* Include the library that allows formatting  */
#include <cmath>       /*Include the math library */
using namespace std;   /*Allow operations from standard library */

int main()
{
    cout << "Clarissa Danif hw1bCD.cpp GE 1111- M, W, TH 10:30 \n" << endl; 
    ofstream outfile;                /* Declare the variables to write to a file */
    outfile.open("hw1bCD.txt");     /* Open output file to write to */ 
    //Variables usnames:
    double m;
    double n;
    // C++ c
    cout << "Please enter the base number\n";
    cin>> m; 
    cout<< "Please enter the power\n";
    cin>> n;
    // Start the if loop
    if (m<0 || n<0)
    {
       cout<< "Error, please enter positive integers";
    } 
    else 
    {
       cout<< "m^n =  "<<pow(m,n)<<"\n";
    }
    // C++ c
    cout << "Please enter the base number\n";
    cin>> m;
    cout<< "Please enter the power\n";
    cin>> n;
    outfile << "Base is " <<m<< " and exponent power is " << n << ".\n"; 
    // Start the if loop
    if (m<0 || n<0)
    {
       cout<< "Error, please enter positive integers";
     } 
     else 
    {
    cout<< "m^n =  "<<pow(m,n)<<"\n";
    outfile << "m^n =  " <<pow(m,n)<< ".\n"; 
    }
    // C++ c
     cout << "Please enter the base number\n";
    cin>> m;
    cout<< "Please enter the power\n";
    cin>> n;
    outfile << "Base is " <<m<< " and exponent power is " << n << ".\n"; 
    // Start the if loop
    if (m<0 || n<0)
    {
       cout<< "Error, please enter positive integers";
    } 
    else 
    {
       cout<< "m^n =  "<<pow(m,n)<<"\n";
       outfile << "m^n =  " <<pow(m,n)<< ".\n"; 
    }
    system("pause"); //To hold dos window
    return 0;
} //To close main function

看起来链接器正在hwtest.o和main.o中找到main方法。这表明您的main.cc文件包含hwtest.cc或hwtest.h,其中也包含main方法。欢迎使用堆栈溢出。我建议您在发布代码之前删除代码中的个人详细信息。在一个单独的例子中,如果你提供一个关于你的问题的最小的例子,你会得到更好的答案。请阅读和
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
"/usr/bin/make"  -f nbproject/Makefile-Debug.mk dist/Debug/GNU-MacOSX/hwtest
mkdir -p dist/Debug/GNU-MacOSX
g++     -o dist/Debug/GNU-MacOSX/hwtest build/Debug/GNU-MacOSX/hwtest.o build/Debug/GNU-           MacOSX/main.o 
duplicate symbol _main in:
build/Debug/GNU-MacOSX/hwtest.o
build/Debug/GNU-MacOSX/main.o
ld: 1 duplicate symbol for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [dist/Debug/GNU-MacOSX/hwtest] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2