C
Chandrashekara Adiga
hi
This is particular to Containment classes .. ( just taking an
example from rougewave )
Can someone point out How destrutor of new RWDate(2, "Nov", 1980)
will be called?
Is is our responsibilty to call it or such container after deleting
the list element calls the destuctor also .
Will appreciate any pointer in this regard ..
RWTPtrHashDictionary<RWCString, RWDate>
birthdays.insertKeyAndValue (new RWCString("Ivan"), new RWDate(2,
"Nov", 1980) );
Thanks
CAdiga
#include <rw/tphdict.h>
#include <rw/cstring.h>
#include <rw/rwdate.h>
#include <rw/rstream.h>
main() {
RWTPtrHashDictionary<RWCString, RWDate>
birthdays(RWCString::hash);
birthdays.insertKeyAndValue
(new RWCString("John"),
new RWDate(12, "April", 1975)
);
birthdays.insertKeyAndValue
(new RWCString("Ivan"),
new RWDate(2, "Nov", 1980)
);
// Alternative syntax:
birthdays[new RWCString("Susan")] =
new RWDate(30, "June", 1955);
birthdays[new RWCString("Gene")] =
new RWDate(5, "Jan", 1981);
// Print a birthday:
RWCString key("John");
cout << *birthdays[&key] << endl;
birthdays.clearAndDestroy();
return 0;
}
This is particular to Containment classes .. ( just taking an
example from rougewave )
Can someone point out How destrutor of new RWDate(2, "Nov", 1980)
will be called?
Is is our responsibilty to call it or such container after deleting
the list element calls the destuctor also .
Will appreciate any pointer in this regard ..
RWTPtrHashDictionary<RWCString, RWDate>
birthdays.insertKeyAndValue (new RWCString("Ivan"), new RWDate(2,
"Nov", 1980) );
Thanks
CAdiga
#include <rw/tphdict.h>
#include <rw/cstring.h>
#include <rw/rwdate.h>
#include <rw/rstream.h>
main() {
RWTPtrHashDictionary<RWCString, RWDate>
birthdays(RWCString::hash);
birthdays.insertKeyAndValue
(new RWCString("John"),
new RWDate(12, "April", 1975)
);
birthdays.insertKeyAndValue
(new RWCString("Ivan"),
new RWDate(2, "Nov", 1980)
);
// Alternative syntax:
birthdays[new RWCString("Susan")] =
new RWDate(30, "June", 1955);
birthdays[new RWCString("Gene")] =
new RWDate(5, "Jan", 1981);
// Print a birthday:
RWCString key("John");
cout << *birthdays[&key] << endl;
birthdays.clearAndDestroy();
return 0;
}