C++ Redefinition Header Files (winsock2.h)
问题 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:\