#include <iostream>
#include <conio.h>
#include <vector>
using namespace std;
class DICHVU
{
protected:
int tiendv;
int dongia;
public:
DICHVU() { tiendv = 0; dongia = 0; }
DICHVU(int _dongia) { dongia = _dongia;}
int getTienDV() { return tiendv; }
virtual void inDV
() { cout<<"\nClass DICHVU";} //Virtual Func };
class THUE_XE : public DICHVU
{
int gio_thue;
public:
THUE_XE() : DICHVU(){ gio_thue = 0; }
THUE_XE(int _gio_thue, int _dongia) : DICHVU(_dongia)
{
gio_thue = _gio_thue;
tiendv = gio_thue * dongia;
if (gio_thue > 7)
tiendv = tiendv * 0.9;
}
void inDV()//sai chỗ này
{
cout<<"\nSo gio thue: "<<gio_thue
<<"\nDon gia: "<<dongia
<<"\nSo tien: "<<tiendv
; }
};
void main()
{
vector<DICHVU> ds;
DICHVU* temp = new THUE_XE(12, 12);
ds.push_back(*temp);
vector<DICHVU>::iterator i = ds.begin();
(*i).inDV(); // Chạy sai chổ này
ds[0].inDV(); // Dùng vậy thay cho iterator đc ko?
// Vậy thì chạy đúng
DICHVU* temp = new THUE_XE(12, 12);
temp->inDV();
//
_getch();
}