fl wrote:
> Hi,
>
> When I trace through a derived class object, it is found that the base class
> virtual de-constructor is called in the last step of the object creating code.
>
> Here is the base class:
> ............
> class Item_base {
> public:
> virtual Item_base* clone() const
> { return new Item_base(*this); }
> public:
> Item_base(const std::string &book = "",
> double sales_price = 0.0):
> isbn(book), price(sales_price) { }
>
> std::string book() const { return isbn; }
>
> virtual double net_price(std::size_t n) const
> { return n * price; }
>
> // no work, but virtual destructor needed
> // if base pointer that points to a derived object is ever deleted
> virtual ~Item_base() { }
> private:
> std::string isbn; // identifier for the item
> protected:
> double price; // normal, undiscounted price
>
> };
>
>
>
> Below is the derived class:
>
> class Sales_item {
By the way, what makes you call this a derived class?
--
Ian Collins