I created a factory pattern today, and defined two inherited functions in the middle, but I didn’t write content in the main function, directly writing the algorithm in the inherited function. As a result, the error error LNK2001: unresolved external symbol "public: virtual void __thiscall was reported. Various search engines could not solve the error. Finally, I thought it should be an error caused by the undefined function in the parent function. The problem was solved after adding the function definition.
This is a very low-level error. I estimate that only people like me who write code directly in C++ make this error. Record it as a reminder to prevent making the same mistake in the future.
code:
library.h
class rElement{
public:
virtual void getValue(sqlite3_stmt* stmt);
private:
virtual void setMapValue();
protected:
map<string , int > sql_map_str;
};
class beamElement:public rElement{
public:
void getValue(sqlite3_stmt* stmt ) override;
private:
void setMapValue() override;
};
library.h
void rElement::getValue(sqlite3_stmt *stmt) {
}
void rElement::setMapValue() {
}