R
romayankin
Can someone explain what am I doing wrong?
Header:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class CMyBase {
private:
CMyBase(const CMyBase& obj); /* Disable copy constuctor */
void operator=(const CMyBase& obj); /* Disable assignment operator
*/
protected:
CMyBase();
public:
virtual ~CMyBase()=0;
};
class CMyChild : public CMyBase {
public:
CMyChild();
void close();
~CMyChild();
private:
int temp;
};
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Source
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#include "main.h"
CMyChild::CMyChild()
: temp (0)
{
}
CMyChild::~CMyChild() {
close();
}
void CMyChild::close() throw() {
temp = 100;
}
int main(int argc, char **argv)
{
CMyChild child;
child.close();
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I get to link errors:
main.obj : error LNK2019: unresolved external symbol "protected:
__thiscall CMyBase::CMyBase(void)" (??0CMyBase@@IAE@XZ) referenced in
function "public: __thiscall CMyChild::CMyChild(void)"
(??0CMyChild@@QAE@XZ)
main.obj : error LNK2019: unresolved external symbol "public: virtual
__thiscall CMyBase::~CMyBase(void)" (??1CMyBase@@UAE@XZ) referenced in
function "public: virtual __thiscall CMyChild::~CMyChild(void)"
(??1CMyChild@@UAE@XZ)
Header:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class CMyBase {
private:
CMyBase(const CMyBase& obj); /* Disable copy constuctor */
void operator=(const CMyBase& obj); /* Disable assignment operator
*/
protected:
CMyBase();
public:
virtual ~CMyBase()=0;
};
class CMyChild : public CMyBase {
public:
CMyChild();
void close();
~CMyChild();
private:
int temp;
};
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Source
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#include "main.h"
CMyChild::CMyChild()
: temp (0)
{
}
CMyChild::~CMyChild() {
close();
}
void CMyChild::close() throw() {
temp = 100;
}
int main(int argc, char **argv)
{
CMyChild child;
child.close();
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I get to link errors:
main.obj : error LNK2019: unresolved external symbol "protected:
__thiscall CMyBase::CMyBase(void)" (??0CMyBase@@IAE@XZ) referenced in
function "public: __thiscall CMyChild::CMyChild(void)"
(??0CMyChild@@QAE@XZ)
main.obj : error LNK2019: unresolved external symbol "public: virtual
__thiscall CMyBase::~CMyBase(void)" (??1CMyBase@@UAE@XZ) referenced in
function "public: virtual __thiscall CMyChild::~CMyChild(void)"
(??1CMyChild@@UAE@XZ)