基类的调用基方法或驱动方法的对象都具有相同的名称..... [英] object of base class call base method or drived method both have same name.....

查看:68
本文介绍了基类的调用基方法或驱动方法的对象都具有相同的名称.....的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个abc类,它具有方法add().......
继承类xyz具有相同的方法add()...
因此,如果我们创建一个基类对象,那么该对象将调用whic方法...
基本或驱动类方法

we have a class abc which has method add().......
inherit it class xyz have same method add()...
so if we make a object of base class then this object call whic method...
base or drived class method

推荐答案

不要担心其他问题.

您写道:如果我们创建基类的对象,那么该对象将调用whic方法"

它将始终调用基类方法.基类不知道继承的类.函数是否被声明为虚拟都无关紧要.直到创建继承类的实例后,您才需要为此担心.
Don''t worry about the others.

You wrote "if we make a object of base class then this object call whic method"

It will always call the base class method. The base class doesn''t know about the inherited class. It doesn''t matter if the function is declared virtual or not. It''s not until you create an instance of the inherited class you have to worry about this.


这取决于它是否是虚拟的.有了这样的理解水平(非常糟糕的写作;这简直是不礼貌),您还不准备在这里提问.首先,在OOP上阅读( http://en.wikipedia.org/wiki/Object-oriented_programming [ ^ ]),通过手册和练习学习C ++和/或C#.

如果这样做了,就不可能问这样的问题.

另外,这里有一些学习指南供您参考:我的程序有问题.请帮忙! [
It depends on if it is virtual or not. With this level of understanding (and very bad writing; this is simply impolite) you''re not ready to ask questions here. First, read on OOP (http://en.wikipedia.org/wiki/Object-oriented_programming[^]), learn C++ and/or C# by manuals and exercises.

If you did, it would not be possible that you asked such questions.

Also, here are some learning guidance for your information: I have a problem with my program. Please help![^], locate and read my answer.

—SA


我们有一个abc类,它具有方法add()........
继承它,类xyz具有相同的方法add()...
因此,如果我们创建一个基类对象,那么该对象将调用whic方法...
基本或驱动类方法


没有人会回答.这很简单.几乎不需要5分钟.尝试一下,检查一下即可.请不要期望完整的汤匙喂食! :doh:
we have a class abc which has method add().......
inherit it class xyz have same method add()...
so if we make a object of base class then this object call whic method...
base or drived class method


No one will answer that. It''s simple. Will take hardly 5 minutes. Just try, do it and check it. Please don''t expect a complete spoon-feed! :doh:


这篇关于基类的调用基方法或驱动方法的对象都具有相同的名称.....的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆