OOP Programming Paradigm Sample


Class:

class data
{
public:
Date(int mn, int dy, int yr); //Constructor
void display(); //Function to print data
~Date(); //Destructor
Private:
int month, day, year; //Private data members
};

Inheritance:

class Employee
{
public:
Employee();
const char *getName() const;
private:
char name[30];
};

class WageEmployee : public Employee
{
public:
WageEmployee(const char *nm);
void setWage(double wg);
void setHours(double hrs);
private:
double:wage;
double:hours;
};
WageEmployee aWorker("Bill Gates");
const char *str;

aWorker.setHours(40.0); //call WageEmployee::setHours
str = aWorker.getName(); //call Employee::getname