#ifndef _INHERIENCE_H_
#define _INHERIENCE_H_
#include <iostream>
using namespace std;
class vehicle{
private:
char* id;
double price;
char* owner;
public:
vehicle(char* iden = NULL, double pri = -1, char* own = NULL){
id = iden;
price = pri;
owner = own;
}
~vehicle(){ }
char* get_id() const{
return id;
}
virtual double get_price() const{
cout<<"This is in base!"<<endl;
return price;
}
char* get_owner() const{
return owner;
}
};
class bike: public vehicle {
private:
int a1;
char* get_id() const{
return NULL;
}
public:
bike(char* iden = NULL, double pri = -1, char* own = NULL, int a = 0) : vehicle(iden, pri, own){
a1 = a;
}
//~bike(){}
double get_price() const{
cout<<"This is in bike!"<<endl;
return 2 * vehicle::get_price();
}
};
#endif
#include "inherience.h"
int main(){
char* iden = NULL;
const vehicle a("skides", 10000, "fool");
bike b("skides", 10000, "fool", 1);
const vehicle* vobj = NULL;
vobj = &a;
vobj->get_price();
vobj = &b;
vobj->get_price();
return 0;
}