主题:有段代码,总是有错误,想不通,请大家帮我看下,谢谢
我初学
public void RectTriangle(int a,int b):base(va,vb,(int)Math.Sqrt(va*va+vb*vb)))
这句总是提示我格式错误,标点什么的,是下面代码的最后面
using System;
namespace MyShape
{
public class Shape
{
public virtual void Draw()
{;}
public virtual int GetArea(){
return 0;
}
}
}
using System;
namespace MyShape
{
public class Triangle:Shape
{
protected int a;
protected int b;
protected int c;
public Triangle(int va,int vb,int vc)
{
a=va;
b=vb;
c=vc;
}
public override int GetArea()
{
int s=(a+b+c)*2;
int area=(int)(Math.Sqrt(s*(s-a)*(s-b)*(s-c)));
return area;
}
public class TectTriangle:Triangle
{
new protected int a;
new protected int b;
public void RectTriangle(int a,int b):base(va,vb,(int)(Math.Sqrt(va*va+vb*vb)))
{
a=va;
b=vb;
}
}
}
public void RectTriangle(int a,int b):base(va,vb,(int)Math.Sqrt(va*va+vb*vb)))
这句总是提示我格式错误,标点什么的,是下面代码的最后面
using System;
namespace MyShape
{
public class Shape
{
public virtual void Draw()
{;}
public virtual int GetArea(){
return 0;
}
}
}
using System;
namespace MyShape
{
public class Triangle:Shape
{
protected int a;
protected int b;
protected int c;
public Triangle(int va,int vb,int vc)
{
a=va;
b=vb;
c=vc;
}
public override int GetArea()
{
int s=(a+b+c)*2;
int area=(int)(Math.Sqrt(s*(s-a)*(s-b)*(s-c)));
return area;
}
public class TectTriangle:Triangle
{
new protected int a;
new protected int b;
public void RectTriangle(int a,int b):base(va,vb,(int)(Math.Sqrt(va*va+vb*vb)))
{
a=va;
b=vb;
}
}
}