Hello,
I am getting the follwoing error in my program:
*** glibc detected *** free(): invalid pointer
The program is as follows.
int main()
{
operation1* sjob1 = new operation1();
answer* ans1 = sjob1->execute();
delete sjob1;
operation2* sjob2 = new operation2();
answer* ans2 = sjob2->execute();
return 0;
}
I have the virtual member function execute() of the base class "operation" which is used by the derived classes -"operation1" and "operation2". I am getting th error at the following line in the code.
answer* ans2 = sjob2->execute();
The function execute() is a virtual function and the base class "operation" has all it member functions as virtual. I have tried deleting the object "ans1" also but i get a segmentaion fault if i do that.
Any help is appreciated.
Thanks