Untitled
unknown
plain_text
3 years ago
1.5 kB
10
Indexable
#include <iostream>
using namespace std;
class Phong{
private:
int ma_phong;
string ten_phong;
double don_gia;
public:
static int count;// dua ra tong so phong hien co
//ham tao mac dinh
Phong(){
count ++;//moi khi khoi tao thi se tinh them 1 phong
}
// ham tao co tham so
Phong(int _ma_phong, string _ten_phong, double _don_gia){
ma_phong = _ma_phong;
ten_phong = _ten_phong;
don_gia = _don_gia;
count ++;//moi khi khoi tao thi se tinh them 1 phong
}
//ham huy
~Phong(){
count --;//moi khi huy thi se giam di 1 phong
}
//getter va setter
double getDon_gia(){
return don_gia;
}
void setDon_gia(double x) {
don_gia = x;
}
//ham nhap
void import(){
cin >> ma_phong >>ten_phong >> don_gia;
}
static int soPhong(){
return count;
}
};
class PhongDacBiet : public Phong{
public:
double don_gia;
PhongDacBiet(int _vi_tri, double _chi_so_phuc_vu, double _gia_co_ban){
don_gia = (_vi_tri + _chi_so_phuc_vu) * _gia_co_ban;
}
};
class PhongThuong : public Phong{
public:
double don_gia;
PhongThuong( double _he_so_phong, double _gia_co_ban){
don_gia = _he_so_phong * _gia_co_ban;
}
};
bool sosanh(Phong x, Phong y){
if(x.getDon_gia() > y.getDon_gia()) return true;
else return false;
}
int main()
{
return 0;
}
Editor is loading...