标题:错误求助....3Q
只看楼主
uukkcc
Rank: 1
等 级:新手上路
帖 子:85
专家分:0
注 册:2007-7-24
 问题点数:0 回复次数:2 
错误求助....3Q

做了一个继承类.
详情如下:
using System;
using System.Collections;
using System.Text;

namespace AcceptTest
{
class name
{
string younname;
public name(string uname) //构造赋值;
{
this.younname = uname;
}
public void shownamemsg() //方法显示值
{
Console.WriteLine("你的名字是:{0}", younname);
}
}
class where:name
{
string yourwhere;
public where(string uwhere) //构造赋值;(此处的WHERE提示错误:NAME方法没有采用"0"个参数的重载.请问是什么错?应该怎么改正?谢谢)

{

this.yourwhere = uwhere;
}
public void showwheremsg() //方法显示值
{
Console.WriteLine("你来自{0}", yourwhere);
}
}

class Program
{
static void Main(string[] args)
{
//传值调用.
where wr = new where("beijing");
name nm = new name("uukk");
wr.showwheremsg();
wr.shownamemsg();
}
}
}

2007-10-23 21:16
冰彩虹
Rank: 4
来 自:上海
等 级:贵宾
威 望:14
帖 子:806
专家分:44
注 册:2007-6-28
得分:0 
由于你name定义了构造函数(带参数的),而where又继承name,所以在构造where时,需要构造name,这时就需要给name提供一个参数

public where(string uwhere):base(uwhere)
{
...
}

Flying without wings
2007-10-23 22:07
guoxhvip
Rank: 8Rank: 8
来 自:聖西羅南看臺
等 级:贵宾
威 望:44
帖 子:4052
专家分:135
注 册:2006-10-8
得分:0 

冰彩虹正解


愛生活 && 愛編程
2007-10-23 23:24



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




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

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