繼承

    基類和派生類      

 Rectangle rect =new Rectangle();
 rect.SetWidth(5);
 rect.SetHeight(7);
 Report.Info("矩形面積:"+rect.getArea());
 class shape{
		
		public void SetWidth(int W){

			Width=W;
		}
		public void SetHeight(int H){
			
			Height=H;
		}
		 protected int Width;
		 protected int Height;
		}
	
	class Rectangle:shape{
		
		public int getArea(){
			return (Width*Height);
		}
	 }

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章