S
SamuelXiao
-----------------------Lab002.h------------------------------
#ifndef _LAB_002_
#define _LAB_002_
class base{
char *msg;
public:
base(char *);
~base();
void print(void);
};
class derived1 : base{
public:
derived1(char *);
~derived1();
};
class derived2 : derived1{
public:
derived2(char *);
~derived2();
};
#endif
----------------------------main.cpp------------------------------
#include <iostream>
#include "Lab002.h"
using namespace std;
void main(void){
derived2 x("X");
{
derived2 y("Y");
}
derived2 z("Z");
}
-------------compiler complaint------------------------------------
__thiscall derived2::derived2(char *)" (??0derived2@@QAE@PAD@Z)
referenced in function _main
what 's wrong with it?
#ifndef _LAB_002_
#define _LAB_002_
class base{
char *msg;
public:
base(char *);
~base();
void print(void);
};
class derived1 : base{
public:
derived1(char *);
~derived1();
};
class derived2 : derived1{
public:
derived2(char *);
~derived2();
};
#endif
----------------------------main.cpp------------------------------
#include <iostream>
#include "Lab002.h"
using namespace std;
void main(void){
derived2 x("X");
{
derived2 y("Y");
}
derived2 z("Z");
}
-------------compiler complaint------------------------------------
1>main.obj : error LNK2019: unresolved external symbol "public:main.obj : error LNK2019: unresolved external symbol "public: __thiscall derived2::~derived2(void)" (??1derived2@@QAE@XZ) referenced in function _main
__thiscall derived2::derived2(char *)" (??0derived2@@QAE@PAD@Z)
referenced in function _main
what 's wrong with it?