I've got a program which works but when I try to implement a destructor in the base call and make it a virtual pure function it doesnt want to work with the rest of the system ...


circle.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall Shape::~Shape(void)" (??1Shape@@UAE@XZ)
rectangle.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall Shape::~Shape(void)" (??1Shape@@UAE@XZ)
Debug/main.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

Any ideas?

Can you post your code? Preferrably something small that still exhibits the problem.

heres the base class:

class Shape
  {
    public:
       Shape(int,int) ;
       Shape () ;
      virtual  ~Shape() =0;
      virtual void print()const = 0;
      virtual double calArea() = 0;
      	  
    protected:
     int  centreX,centreY;
   };

#endif

now from that you can see the the destructor is virtual and is pure meaning no function body needs defining

but when I write an implemenation is the other class's it doesnt like it!

I have included a zip of all the files .......

Rather than download and unzip your attachment, then screw around with your code to get it running on my implementation, I'll make you try this first:

virtual  ~Shape() =0 {}

i works doing that, can you explain why you need '{}' for destrutors and not for the others?

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.