特殊工具和技术
allocator类PTTI类成员的指针嵌套类union局部类位域volatileexter "C"
#include <iostream>
using namespace std;
class Item_base
{
public:
virtual double net_price(size_t n) const;
{
return n* price;
}
public:
std::string isbn;
protected:
double price;
};
class Bulk_item: public Item_base
{
public:
double net_price(std::size_t cnt)
{
if(cnt>min_qty)
return cnt * price;
}
private:
std::size_t min_qty;
double discount;
};
int main()
{
Item_base *pItem = new Item_base();
allocator<Item_base> a; //分配内存
a.allocator(100);
system("pause");
return 0;
}