redefinition

C++ Redefinition Header Files (winsock2.h)

萝らか妹 提交于 2019-11-26 02:17:34
问题 How do I prevent from including header files twice? The problem is I\'m including the in MyClass.h and then I\'m including MyClass.h in many files, so it includes multiple times and redefinition error occurs. How to prevent? I\'m using #pragma once instead of include guards, and I guess that\'s fine. MyClass.h: // MyClass.h #pragma once #include <winsock2.h> class MyClass { // methods public: MyClass(unsigned short port); virtual ~MyClass(void); }; EDIT: Few of the errors I\'m getting c:\