How to correctly define and link a C++ class destructor to a main file?
问题 This is a particularized question from mingw32/bin/ld.exe ... undefined reference to [class] ... collect2.exe: error: ld returned 1 exit status There is a user-defined class inside MyClass.hpp: class MyClass { public: MyClass(const string& className); ~MyClass() {cout << "Destructor definition instead of g++ default one?";} ; ... and you try to construct an object out of it in the main file: #include "MyClass.hpp" //in the same directory ... int main() { ... MyClass myClassObj = MyClass