简体   繁体   中英

Unresolved external symbol c++ for inheritance and constructor

//Baseclass.h
class Baseclass {
private:
    uint8_t index;
public:
    Baseclass(uint8_t index);
}

//Baseclass.cpp
#include "Baseclass.h"
Baseclass::Baseclass(uint8_t index) {
    index = index;
};

//Subclass.h
#include "Baseclass.h"
class Subclass : public Baseclass {
public:
    Subclass();
};

//Subclass.cpp
#include "Subclass.h"
#include "Baseclass.h"
Subclass::Subclass() : Baseclass(0) {};

What am I missing? I kept getting LNK2019 Error

Severity Code Description Project File Line Suppression State Error

LNK2019 unresolved external symbol "public: __thiscall Baseclass::Baseclass(unsigned char)" (??Baseclass@@QAE@E@Z) referenced in function "public: __thiscall Subclass::Subclass(void)" (??Subclass@@QAE@XZ)    

It couldn't link Baseclass constructor. Are you sure there are no issues with compiling it? If you copy pasted all of the code you lack semicolon at the end of baseclass.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM