Collect2.exe [错误] ld返回1退出状态

时间:2017-09-11 15:14:41

标签: c++

我做了一个简单的程序

#include<iostream>
#include <stdio.h>
using namespace std;

class x
{
    private:
        int y;


    public:
     x()
    {
        y=0;
    }

    void incrementy()
    {
        y=0+1;
    }

    void show()
    {
    cout<<("y is:"+y)<<endl;
    }

    int main()
    {
        x*showy = new x();
        showy->show();
        return 0;


    }

};

但是当我编译时,我会收到错误,例如:

C:\Users\Jevaughn\Documents\collect2.exe    [Error] ld returned 1 exit status

18 C:\crossdev\src\mingw-w64-v3-git\mingw-w64-crt\crt\crt0_c.c  undefined reference to `WinMain'

我不确定这些错误是指什么以及如何解决它们。非常感谢任何帮助。

1 个答案:

答案 0 :(得分:0)

#include<iostream>
#include <stdio.h>
using namespace std;

class x
{
    private:
        int y;


     public:
      x()
     {
         y=0;
     }

void incrementy()
{
    y=0+1;
}

void show()
{
cout<<"y is:"<<y<<endl;
}
};

int main()
     x* showy = new x();
     showy->show();
     return 0;
}