D
DJ.precario
Hi everyone,
I am having a linking problem, and I'd appreciate any help with this.
The code showing the problem:
class base {
public:
virtual void f(int);
};
#include <iostream>
#include "base.h"
using namespace std;
class derived : public base
{
public:
derived() { cout << "Object of the class derived created\n"; };
virtual void f(int);
};
#include <iostream>
#include "derived.h"
using namespace std;
void derived::f(int numb)
{
cout << "number received is: " << numb << endl;
}
#include <iostream>
#include "derived.h"
#include "base.h"
using namespace std;
int main()
{
base *b;
b = new derived;
int numb = 33;
b->f(numb);
delete b;
return 0;
}
I get this linker error:
Linking...
main.obj : error LNK2001: unresolved external symbol "public: virtual
void __thiscall base::f(int)" (?f@base@@UAEXH@Z)
..\Debug/Tests.exe : fatal error LNK1120: 1 unresolved externals
Can anyone give me a pointer towards what's happening? (I am using
Visual Studio .NET 2003)
I am having a linking problem, and I'd appreciate any help with this.
The code showing the problem:
class base {
public:
virtual void f(int);
};
#include <iostream>
#include "base.h"
using namespace std;
class derived : public base
{
public:
derived() { cout << "Object of the class derived created\n"; };
virtual void f(int);
};
#include <iostream>
#include "derived.h"
using namespace std;
void derived::f(int numb)
{
cout << "number received is: " << numb << endl;
}
#include <iostream>
#include "derived.h"
#include "base.h"
using namespace std;
int main()
{
base *b;
b = new derived;
int numb = 33;
b->f(numb);
delete b;
return 0;
}
I get this linker error:
Linking...
main.obj : error LNK2001: unresolved external symbol "public: virtual
void __thiscall base::f(int)" (?f@base@@UAEXH@Z)
..\Debug/Tests.exe : fatal error LNK1120: 1 unresolved externals
Can anyone give me a pointer towards what's happening? (I am using
Visual Studio .NET 2003)