标题:怎么不成功呀
取消只看楼主
nyzfl
Rank: 1
等 级:新手上路
帖 子:278
专家分:0
注 册:2005-3-21
 问题点数:0 回复次数:4 
怎么不成功呀
using System;
class Test
{
 public static void Main()
 {
  
  float[] vals={(float)2.0,(float)3.0};
  Quad q=new Quad(Val[0],Val[1]);
  Triangle t=new Triangle(Val[0],Val[1]);
  Console.WriteLine("Quad area is {0}",q.GetArea());
  Console.WriteLine("Triangle area is {0}",t.GetArea());
 }
}
public abstract class Shape
{
 protected float width;
 protected float height;
 public Shape(float w,float h)
 {
  width=w;
  height=h;
 }
 public abstract float GetArea();
}
public class Quad:Shape
{
 public Quad(float w,float h):base(w,h)
 {
 }
 public override float GetArea()
 {
  return width*height;
 }
}
public class Triangle:Quad
{
 public Triangle(float w,float h):base(w,h)
 {
 }
 public override float GetArea()
 {
  return 0.5F*width*height;
 }
}
搜索更多相关主题的帖子: Triangle public float Quad abstract 
2005-04-07 11:59
nyzfl
Rank: 1
等 级:新手上路
帖 子:278
专家分:0
注 册:2005-3-21
得分:0 
不能运行

My-Blog地址:http://fenglin.
2005-04-07 16:32
nyzfl
Rank: 1
等 级:新手上路
帖 子:278
专家分:0
注 册:2005-3-21
得分:0 
不是吧

My-Blog地址:http://fenglin.
2005-04-07 16:38
nyzfl
Rank: 1
等 级:新手上路
帖 子:278
专家分:0
注 册:2005-3-21
得分:0 
visual c#.net

My-Blog地址:http://fenglin.
2005-04-07 16:55
nyzfl
Rank: 1
等 级:新手上路
帖 子:278
专家分:0
注 册:2005-3-21
得分:0 
名称“val”在类或命名空间“test”不存在

My-Blog地址:http://fenglin.
2005-04-07 16:59



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-14981-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.726160 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved