Warning related to Wrapper.h

This forum is to discuss the book "C++ design patterns and derivatives pricing."

Warning related to Wrapper.h

Postby pariski » Mon Jun 08, 2015 10:15 pm

Hello,
I tried to compile the code from chapter 6 (or chapter 5, 7), I got the following warning:
$ make -f makefileR
g++ -o RandomMain3 RandomMain3.cpp AntiThetic.cpp ParkMiller.cpp Normals.cpp \
Arrays.cpp ConvergenceTable.cpp SimpleMC8.cpp MCStatistics.cpp \
Parameters.cpp Vanilla3.cpp PayOff3.cpp PayOffBridge.cpp Random2.cpp
In file included from RandomMain3.cpp:5:
In file included from ./ConvergenceTable.h:4:
./Wrapper.h:13:3: warning: delete called on 'RandomBase' that is abstract but has non-virtual destructor [-Wdelete-non-virtual-dtor]
delete DataPtr;
^
RandomMain3.cpp:40:23: note: in instantiation of member function 'Wrapper<RandomBase>::~Wrapper' requested here
AntiThetic GenTwo(generator);
^
1 warning generated.
In file included from AntiThetic.cpp:1:
In file included from ./AntiThetic.h:5:
./Wrapper.h:13:3: warning: delete called on 'RandomBase' that is abstract but has non-virtual destructor [-Wdelete-non-virtual-dtor]
delete DataPtr;
^
AntiThetic.cpp:3:13: note: in instantiation of member function 'Wrapper<RandomBase>::~Wrapper' requested here
AntiThetic::AntiThetic(const Wrapper<RandomBase>& innerGenerator):
^
1 warning generated.



It seems that the compiler is complaining about the wrapper.h, where the destructor is non-virtual. Will this be a problem? How can I fix this?

Thank you.
pariski
 
Posts: 2
Joined: Wed May 27, 2015 9:57 pm

Re: Warning related to Wrapper.h

Postby mj » Wed Jun 10, 2015 12:08 am

putting a virtual on a destructor in RandomBase should fix this.

virtual ~RandomBase(){}
mj
Site Admin
 
Posts: 1380
Joined: Fri Jul 27, 2007 7:21 am


Return to C++ design patterns and derivatives pricing

Who is online

Users browsing this forum: No registered users and 1 guest

cron