In integration.h I have this

class FunctionClass
{
	public:
		virtual double f(const double x) = 0;
};

Then in probability.h, I have this

#include "integration.h"

class Mass1 : public FunctionClass
{
	public:
		double Clutter;

		Mass1(double c) : Clutter(c) {}

		double f(const double x)
		{
			return Clutter * exp(-Clutter * x);
		}

};

That works perfectly. However, if I change it to

#include "integration.h"

class Mass1 : public FunctionClass
{
	public:
		double Clutter;

		Mass1(double c) : Clutter(c) {}

		double f(const double x);
};

and then in probability.cpp put

#include "probability.h"
		double f(const double x)
		{
			return Clutter * exp(-Clutter * x);
		}

I get this vtable error. What have I done wrong?

Thanks,

Dave

Recommended Answers

All 4 Replies

In probability.cpp try changing the following double f(const double x) to double Mass1::f(const double x) .

Adam

oh sorry, that was correct, i just posted it wrong.

However, I found the problem. It was simply that I was not linking to the probability.cpp. So I guess when a virtual function definition is not found it gives that vtable error?

Thanks,
Dave

What compiler? I usually get a more detailed error than that.

I've had a look at re-creating this problem but my compiler (vc++ 9) would only throw a unresolved external for this.

My best guess would be that as the class was not compiled with required functions and the vtable was not created properly for the class(es).

... but I'm a little rusty on this.

Adam.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.