I am trying to get the program below to work. I keep getting the error below, and I can't figure out why???
Derived.obj : error LNK2001: unresolved external symbol "public: virtual class Other * __thiscall Derived::add(int,int)" (?add@Derived@@UAEPAVOther@@HH@Z)
#ifndef _BASE_H_
#define _BASE_H_
#include "Other.h"
class Base{
public:
virtual Other *add(int x, int y) = 0;
};
#endif // !defined _BASE_H_
#ifndef _DERIVED_H_
#define _DERIVED_H_
#include "Base.h"
class Derived : public Base{
public:
Derived();
virtual Other *add(int x, int y);
};
#endif
#include "Derived.h"
Derived::Derived()
{
}
Other *add(int x, int y)
{
int z = (x + y);
return new Other (z);
}
#ifndef _OTHER_H_
#define _OTHER_H_
class Other{
public:
Other();
Other(int val);
private:
int value;
};
#endif
#include "Other.h"
Other::Other()
{
}
Other::Other(int val)
{
value = val;
}
#include <iostream>
#include <string>
#include "Derived.h"
#include "Other.h"
using namespace std;
int main ()
{
Derived derived;
// Other * other;
// other = (derived.add(4,6));
// cout << z << endl;
system("pause");
return 0;
}