
2 Dec
2008
2 Dec
'08
6:02 p.m.
AMDG sam p wrote:
I am using polymorphic archive in my code and I am using it as follows,
1 void func(std::stringstream &ss, boost::archive::polymorphic_oarchive *&ptr) 2 { 3 ptr = new boost::archive::polymorphic_text_oarchive(ss); 4 return; 5 } 6 int main() 7 { 8 std::stringstream ss; 9 boost::archive::polymorphic_oarchive *ptr = NULL; 10 func(ss, ptr); 11 delete ptr; //Will this delete object properly????? 12 }
Now the question is, whether 'delete' one line no. 11 will work properly or not? And is this a right way to use polymorphic archive?
Yes. polymorphic_oarchive has a virtual destructor. In Christ, Steven Watanabe