Untitled
unknown
plain_text
3 years ago
1.1 kB
8
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;
}
};
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...