遗产 [英] Inheritance
问题描述
在继承关系中,下列哪种方法最有可能是虚拟的?
a)构造函数
b)析构函数
c)复制构造函数
d)以上都不是
In an inheritance relationship, which one of the following methods is most likely to be virtual?
a) Constructor
b)Destructor
c) Copy Constructor
d) None of the above
推荐答案
以下哪种方法最有可能是虚拟的?
which one of the following methods is most likely to be virtual?
你的问题中没有方法
No method is there in your question
在继承关系中,下列哪种方法最有可能是虚拟的?
In an inheritance relationship, which one of the following methods is most likely to be virtual?
第一个。
:-D
The first one.
:-D
在继承关系中,以下哪一项方法最有可能是虚拟的吗?
In an inheritance relationship, which one of the following methods is most likely to be virtual?
当你有一个你希望由继承类实现的类中的函数,你可以使用虚函数,她的代码用于演示
when u have a function in your class which you want to be implemented by the inherited class you can use the virtual function, hers a code for demonstration
using System;
//base class
class parent
{
//with a virtual function
public virtual void myfunction()
{
Console.WriteLine("Hi i am virtual function");
}
}
class child: parent
{
//attempt to override the parent class function called myfunction
public override void myfunction()
{
Console.WriteLine("I am Legend");
}
//making another virtual function which is to be overriden
public virtual void hellboy()
{
Console.WriteLine("My name is Hellboy");
}
}
//now radix class inherits child which means child is the parent for radix, radix can override th parent class function too but i have not done this
class Radixx :child
{
public override void hellboy()
{
Console.WriteLine("My name is Radix and i am a programmer");
}
}
class implement
{
public void cl(parent p)
{
//calling myfunction
p.myfunction();
}
public void arsenal(Radixx rad)
{
//calling hellboy function
rad.hellboy();
}
}
class calling
{
static void Main()
{
implement obj = new implement();
child radix = new child();
obj.cl(radix); //see the magic here
Radixx rdx = new Radixx();
obj.arsenal(rdx); //Magic here too
}
}
一旦找到它,请给我的答案评分有用的
谢谢&问候
Radix:rose:
Do rate my answer once you find it useful
Thanks & Regards
Radix :rose:
这篇关于遗产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!