// CIS 235 Lecture 09 // Inheritance // Base Class invent ( Called supperclass in Java ) #ifndef INV_H #define INV_H #include using std::ostream; #include using namespace::std; class invent { public: invent( const invent &); // copy constructor invent( void); // default constructor invent( long c, long n, double cst, double p); virtual ~invent(void); // declared to be virtual to insure // that derived class destructors will be called // if the memory was acquired using a base // class pointer invent & setPrice(double); invent & setNumber(long); invent & setCost(double); invent & setCode(long); double getPrice(void) const; double getCost(void) const; long getNumber(void) const; long getCode(void) const; double getRetailValue(void) const; // Declaring a base class member function makes it polymorphic // virtual is a sticky attribute - it cannot be removed // in derived classes // virtual can be declared in the derived class, but is // NOT NECESSARY virtual string identify(void) const; // will return the class name // since virtual, cannot be static virtual const invent & print(ostream &) const; virtual invent & kinput(void); private: double price; // retail price per unit double cost; // wholesale cost per unit long code; // product id number long number; // number in stock }; #endif