Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- class hinhchunhat {
- public :
- hinhchunhat();
- void set_cach(int, int);
- void get_canh();
- void dientich(int, int);
- private :
- int chieudai;
- int chieurong;
- };
- class hinhhop: public hinhchunhat {
- private:
- int chieucao;
- int chieurong;
- int chieudai;
- public:
- hinhhop();
- void set_chieucao(int);
- void get_chieucao();
- void thetich(int, int, int);
- };
- hinhhop::hinhhop(){
- chieudai = 0;
- chieurong = 0;
- chieucao = 0;
- }
- void hinhhop::set_chieucao(int chieucao) {
- this->chieucao = chieucao;
- }
- void hinhhop::get_chieucao() {
- cout << "chieu cao : " << chieucao;
- }
- void hinhhop::thetich(int chieudai, int chieurong, int chieucao) {
- cout << "thetich :" << chieudai*chieurong*chieucao;
- }
- hinhchunhat::hinhchunhat() {
- chieudai = 0;
- chieurong = 0;
- }
- void hinhchunhat::set_cach(int chieudai, int chieurong) {
- this->chieudai = chieudai;
- this->chieurong = chieurong;
- }
- void hinhchunhat::get_canh() {
- cout << chieudai << " " << chieurong;
- }
- void hinhchunhat::dientich(int chieudai, int chieurong) {
- cout << "dientich :" << chieudai*chieurong;
- }
- void main() {
- hinhchunhat a;
- hinhhop b;
- a.set_cach(4, 6);
- a.get_canh();
- a.dientich(5, 7);
- b.set_cach(4, 5);
- b.set_chieucao(6);
- b.get_canh
- b.thetich(6, 7, 8);
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement