[ create a new paste ] login | about

Link: http://codepad.org/t4QXdvMl    [ raw code | output | fork ]

C++, pasted on Oct 14:
#include<iostream.h>
class  HCN
{
	private:
		float	d,r;
	public:
		HCN (float d,float r)
		{
			this->d=d;
			this->r=r;
		}
	
		float tinhchuvi();	
		friend float tinhdientich(HCN h);
		void  inthongtin();
		friend void nhap(HCN &h);
};

void  HCN :: inthongtin()
{
	cout<<"("<<d<<","<<r<<")";
}
float  HCN :: tinhchuvi()
{
	return  2*(d+r);
}
float  tinhdientich(HCN h)
{
	return  h.d*h.r ;
}
void nhap(HCN &h)
{
	cout<<"\nmoi nhap chieu dai";cin>>h.d;
	cout<<"\nmoi nhap chieu rong";cin>>h.r;
}
int main()
{
	HCN	h(20,15);
	//h.nhap();
	nhap(h);
	cout<<"\nIn thong tin hinh chu nhat: ";
	h.inthongtin();
	cout<<"\n co chu vi la: "<<h.tinhchuvi()<<"\n va co dien tich la: "<<tinhdientich(h);
	cout<<endl;
	return 0;
}


Output:
1
2
3
4
5
6

moi nhap chieu dai
moi nhap chieu rong
In thong tin hinh chu nhat: (20,15)
 co chu vi la: 70
 va co dien tich la: 300


Create a new paste based on this one


Comments: