这里使用的是重载或重写 [英] what is used here Overloading or Overridding

查看:52
本文介绍了这里使用的是重载或重写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我们有两个函数,比如



int fun1(int,int)

double fun1(int,int)



这是超载还是过度的?

if we have two functions like

int fun1(int,int)
double fun1(int,int)

this is ex of what overloading or overidding?

推荐答案

如果没有此背景,绝对不可能回答码。而且,这个问题根本就没有意义。

这是一种非常糟糕的学习方法。阅读一本简单的手册,做练习,只有在你被困时才提出问题要好得多。



覆盖是一个严重的影响,非常基础和OOP的核心。解释OOP是如何工作的故事太长了,但你需要学习它。



重载只是令人困惑的术语......实际上什么都没有。没有什么是超载,因为没有加载。对于非常简单的情况,这是一个行话:两个或更多完全不同的函数可能具有相同的名称,如果并且因为编译器可以通过不同的签名来区分它们。对于某些呼叫代码,它可能是也可能是不可能的;如果没有,则显示编译错误。



-SA
It is absolutely impossible to answer without the context of this code. Moreover, this question makes no sense at all.
And this is a very poor method of learning something. It''s much better to read a simple manual, do the exercises, and ask question only when you stuck.

Overriding is a serious effect, the very base and the heart of OOP. It''s too long story to explain how OOP works, but you will need to learn it.

Overloading is just the confusing term for... practically nothing. Nothing is "overloaded" because nothing is "loaded". This is a jargon for a very simple situation: two or more totally different functions may have identical name, if and because a compiler can distinguish them by different signature. For certain call codes, it may or may not be possible; if not, a compilation error is shown.

—SA


这篇关于这里使用的是重载或重写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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