首页  >  问答  >  正文

c++ - 老问题error LNK2005: "public: void __thiscall

// A.cpp
#include "A.h"

// A.h
#ifndef _A_H
#define _A_H
class A
{
public:
    A();
    ~A();


private:

};

A::A()
{
}

A::~A()
{
}
#endif
// test.cpp
#include "A.h"
int main(){

}

然后编译就会出现error LNK2005: "public: void __thiscall问题,当删除构造和析构函数可以通过?为什么呢?还有我通过网上说的更改运行时库还是不能编译通过,怎么办??

巴扎黑巴扎黑2646 天前873

全部回复(1)我来回复

  • 伊谢尔伦

    伊谢尔伦2017-06-24 09:45:00

    代码有没有贴全,我在vs2015运行正常。

    
    #include <iostream>
    #include <vector>
    #include <iterator>
    
    using namespace std;
    
    class A
    {
    public:
        A();
        ~A();
    
    private:
    
    };
    
    A::A()
    {
    }
    
    A::~A()
    {
    }
    
    int main() 
    {
        
        
    
        return 0;
    }

    回复
    0
  • 取消回复