search

Home  >  Q&A  >  body text

c++ - old problem 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(){

}

Then error LNK2005: "public: void __thiscall" will appear when compiling. When deleting the constructor and destructor, it can pass? Why? What should I do if I still can't compile the runtime library by changing the runtime library as mentioned on the Internet? ?

巴扎黑巴扎黑2699 days ago912

reply all(1)I'll reply

  • 伊谢尔伦

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

    Have you posted the complete code? I am running it normally in vs2015.

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

    reply
    0
  • Cancelreply