这里是程序设计完全小白一枚……跪求大神帮忙!!
实验目的要求见下,回答请帮忙给出完整且可以在VS05及更高版本运行的C#代码,非常感谢!满意的财富值会追加!!(如果可以请顺便看看我的另一个问题……再次跪谢!!
继承和多态实验目的:
(1)掌握不同继承方式下对基类的成员的访问的控制。(2)掌握使用虚函数实现多态性;(3)掌握运算符重载的方法。
实验内容提要:(任选两题)
(1)设计一个Person类和其派生类教师teacher,新增的属性有专业、职称和主讲课程,并为这些属性定义相应的方法。
(2)设计一个汽车类vehicle,包含的数据成员有车轮个数wheels和车重weight。小车类car是它的公有子类其中包含载人数passenger_load。卡车类truck是vehicle的公有子类其中包含载人数passenger_load和载重量payload,每个类都有相关数据的输出方法。
(3)基类Shape含有一个虚函数Area,由它派生出一个类Point类。Point类有两个数据成员x和y。正方形类从Point类派生,增加一个数据成员:边长;圆类也由Point类派生,增加一个数据成员:半径;圆柱体类从Circle类派生增加一个数据成员:高。编写程序,输出正方形的面积和圆柱体的体积。
(4)定义一个哺乳动物Mammal类,再由此派生出狗Dog类,二者都定义 Speak()成员函数,基类中定义为虚函数,定义一个Dog类的对象,调用Speak函数,观察运行结果。
æ谢帮å¿~ ä½æ¯å¤å¶å°VSéæ¾ç¤ºæé误â¦â¦é½æ¯æåçé£é¨åï¼ä¸å¤ªæ¸
æ¥æä¹æ¹å¨ï¼è½éº»ç¦æ¨å¸®å¿ä¿®æ¹è°è¯ä¸ä¸åâ¦â¦ä¸å¥½ææï¼è¾è¦äºâ¦â¦
çæ¥ä½ æ¯ç没åºç¡ï¼é¦å
ï¼ä½ è¦æ°å»ºä¸ä¸ªæ§å¶å°ç¨åº
ç¶åï¼æ°å»ºä¸ä¸ªç±»ï¼
ç¶åæè¿ä¸ªç±»éé¢ï¼namespace ä¿çï¼æclass å æï¼æ³¨æ{} ç对åº
ç¶åæ ///
/// åºä¹³å¨ç©
///
public class Mammal
{
public virtual void Speak()
{
}
}
///
/// çç
///
public class Dog:Mammal
{
public override void Speak()
{
Console.WriteLine("汪ã汪ã汪");
}
}
æ¾å°namespace ç{}ä¸é´ï¼ç¶åï¼å°ç°æçMainä¸ï¼æè¿éçmainéé¢çå
容å¤å¶è¿å»
ä½ å¥½â¦â¦ 谢谢帮å¿â¦â¦ ä½ä¸ä»æçè¯å¯ä»¥å ä¸QQä¹ç±»çåâ¦â¦æè¿æ¯æç¹â¦â¦ä¸å¤ªæQAQï¼2770245750
选修刷学分啊……本专业和编程一点点关系都没有的……
选修刷学分啊……本专业和编程一点点关系都没有的……
追答楼下的帮你写了,你创建控制台项目,把他代码复制进去就可以运行了
追问并不能运行…你会C#吗…会的话能不能帮忙看一下有什么问题?
追答少写了 Program类。
其他不变,下面的改成这样,也就是加上 class Program{ }
class Program